char函数

MSSQL常用函数(转载)

喜欢而已 提交于 2019-12-16 13:12:34
一、字符转换函数 1、ASCII() 返回字符表达式最左端字符的ASCII 码值。在ASCII()函数中,纯数字的字符串可不用‘’括起来,但含其它字符的字符串必须用‘’括起来使用,否则会出错。 2、CHAR() 将ASCII 码转换为字符。如果没有输入0 ~ 255 之间的ASCII 码值,CHAR() 返回NULL 。 3、LOWER()和UPPER() LOWER()将字符串全部转为小写;UPPER()将字符串全部转为大写。 4、STR() 把数值型数据转换为字符型数据。 STR (<float_expression>[,length[, <decimal>]]) length 指定返回的字符串的长度,decimal 指定返回的小数位数。如果没有指定长度,缺省的length 值为10, decimal 缺省值为0。 当length 或者decimal 为负值时,返回NULL; 当length 小于小数点左边(包括符号位)的位数时,返回length 个*; 先服从length ,再取decimal ; 当返回的字符串位数小于length ,左边补足空格。 二、去空格函数 1、LTRIM() 把字符串头部的空格去掉。 2、RTRIM() 把字符串尾部的空格去掉。 三、取子串函数 1、left() LEFT (<character_expression>, <integer

实验五

一曲冷凌霜 提交于 2019-12-16 13:12:28
/* 假定输入的字符串中只包含字母和*号。 编写函数,实现: 除了字符串前导和尾部的*号之外,将串中其他*号全部删除。 在编写函数时,不得使用C语言提供的字符串函数。 例如,若字符串中的内容为****A*BC*DEF*G******* 删除后,字符串中的内容则应当是****ABCDEFG****** */ #include <stdio.h> #include <string.h> void fun(char *a) { int i=0; char *t = a, *f = a; char *q = a; while(*t)//把t定位到倒数第二个字符 t++; t--; while(*t=='*')//分析第三段 t--; while(*f=='*')//分析第一段 f++; while (q<f) { a[i] = *q; q++; i++; } while (q<t) { if(*q!='*') { a[i] = *q; i++; } q++; } while (*q) { a[i] = *q; i++; q++; } a[i]='\0'; } int main () { char s[81]; printf("Entre a string:\n"); gets(s); fun(s); printf("The sting after deleted:\n"); puts(s)

处理其他资源之二

家住魔仙堡 提交于 2019-12-16 12:49:11
文件打开、关闭的统一管理。 打开文件 —— 处理文件 —— 关闭文件。 那么文件访问的结构体里必须包含文件名、处理方法。这次我们多加一个成员 —— 访问模式。于是 file_reader.h #ifndef _FILE_READER_H_ #define _FILE_READER_H_ #include <stdio.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif typedef struct FileAcessorContext{ const char * const pFname; const char * const pMode; void (* const processor)(struct FileAcessorContext *pThis, FILE *fp); }FileAcessorContext; bool access_file(FileAcessorContext *pCtx); #ifdef __cplusplus } #endif #endif file_reader.c #include "file_reader.h" bool access_file(FileAcessorContext *pCtx){ FILE *fp = fopen(pCtx->pFname, pCtx-

实验5

大憨熊 提交于 2019-12-16 12:14:09
/* 假定输入的字符串中只包含字母和*号。 编写函数,实现: 除了字符串前导和尾部的*号之外,将串中其他*号全部删除。 在编写函数时,不得使用C语言提供的字符串函数。 例如,若字符串中的内容为****A*BC*DEF*G******* 删除后,字符串中的内容则应当是****ABCDEFG****** */ #include <stdio.h> #include <stdlib.h> #include <string.h> void fun(char *a) { /**ERROR******/ int i=0; char *t = a, *f = a; char *q = a; while(*t) t++; t--; while(*t == '*') t--; while(*f == '*') f++; /***ERROR***/ while (q<f) { a[i] = *q; q++; i++; } while (q<t) { /***ERROR**/ if(*q != '*') { a[i] = *q; i++; } q++; } while (*q) { a[i] = *q; i++; q++; } /**ERROR**/ a[i]=0; } int main () { char s[81]; printf("Entre a string:\n"); gets(s); /*

c/c++封装成python包

坚强是说给别人听的谎言 提交于 2019-12-16 11:44:09
参考网址:https://blog.csdn.net/tiankongtiankong01/article/details/80420033 SWIG (Simplified Wrapper and Interface Generator) 是用来为C和C++程序构造脚本语言接口的软件开发工具。SWIG 实际上是一个编译器,获取C/C++的声明,用一个壳包起来,以便通过其他语言访问这些声明。因此,SWIG 最大的好处就是将脚本语言的开发效率和 C/C++ 的运行效率结合起来。 一:准备源文件 文件1:EncryptTool.h int EncryptFile(const char *szInputFile, const char *szOutputFile); int DecryptFile(const char *szInputFile, const char *szOutputFile); 文件2:EncryptTool.cpp # 属于文件1的引用文件或者说是依赖包,后面动态链接将其封装起来 #include <iostream> using namespace std; int EncryptFile(const char *szInputFile, const char *szOutputFile) { char str[] = "jiami"; cout <<

12道Java算法与编程面试题

℡╲_俬逩灬. 提交于 2019-12-16 11:38:51
12道Java算法与编程面试题 自己整理的面试题,希望可以帮到大家,需要更多资料的可以私信我哦,大家一起学习进步! 算法与编程 1、编写一个程序,将a.txt文件中的单词与b.txt文件中的单词交替合并到c.txt文件中,a.txt文件中的单词用回车符分隔,b.txt文件中用回车或空格进行分隔。 答: package cn.itcast; import java.io.File; import java.io.FileReader; import java.io.FileWriter; public class MainClass{ public static void main(String[] args) throws Exception{ FileManager a = new FileManager("a.txt",new char[]{'\n'}); FileManager b = new FileManager("b.txt",new char[]{'\n',' '}); FileWriter c = new FileWriter("c.txt"); String aWord = null; String bWord = null; while((aWord = a.nextWord()) !=null ){ c.write(aWord + "\n"); bWord =

第69课.技巧:自定义内存管理

落爺英雄遲暮 提交于 2019-12-16 10:19:21
1.统计对象中某个成员变量的访问次数 注意:对象(普通对象,只读对象) eg: #include <iostream> #include <string> using namespace std; class Test { int m_value; int * const m_pCount; public: Test(int value = 0) : m_pCount(new int(0)) { m_value = value; } int getValue() const { *m_pCount = *m_pCount + 1; return m_value; } void setValue(int value) { *m_pCount = *m_pCount + 1; m_value = value; } int getCount() const { return *m_pCount; } ~Test() { delete m_pCount; } }; int main() { // 普通对象 Test t; t.setValue(100); cout << "t.m_value = " << t.getValue() << endl; cout << "t.m_count = " << t.getCount() << endl; // 只读对象 const Test ct

c博客作业06-结构体&文件

帅比萌擦擦* 提交于 2019-12-15 21:14:06
1.本章学习总结 1.1 学习内容总结 1.结构体如何定义、成员如何赋值 1.结构体的定义 一般形式: struct 结构名{ 类型名 结构名成员1; 类型名 结构名成员2' ··· 类型名 结构名成员n; }; 结构的嵌套定义: /*设置结构体保存学生的学号,姓名,通行地址,以及计算机,英语,数学和平均成绩,其中通行地址包括,居住的城市,街道,门牌号,邮编*/ struct address { char city[10]; char street[20]; int code; int zip; }; struct nest_student{ int num; char name[10]; struct address addr; int computer,english,math; double auerage; }; 注意:在注意嵌套的结构类型时,必须先定义成员的结构类型,在定义主结构类型。 2.结构体成员的赋值 在c语言中,使用结构成员操作符"."来引用结构成员,格式为 结构变量名.结构成员名 。 /*对学生的信息进行赋值*/ struct student{ int num; char name[10]; int computer,english,math; double average; }; struct student s1,s2; /*分别对s1的每个结构体成员赋值;

C51学习笔记

筅森魡賤 提交于 2019-12-15 21:03:36
一, C51内存结构深度剖析 二, reg51.头文件剖析 三, 浅淡变量类型及其作用域 四, C51常用头文件 五, 浅谈中断 六, C51编译器的限制 七, 小淡C51指针 八, 预处理命令 一,C51内存结构深度剖析 在编写应用程序时,定义一个变量,一个数组,或是说一个固定表格,到底存储在什么地方; 当定义变量大小超过MCU的内存范围时怎么办; 如何控制变量定义不超过存储范围; 以及如何定义变量才能使得变量访问速度最快,写出的程序运行效率最高。以下将一一解答。 1 六类关键字(六类存储类型) data idata xdata pdata code bdata code: code memory (程序存储器也即只读存储器)用来保存常量或是程序。code memory 采用16位地址线编码,可以是在片内,或是片外,大小被限制在64KB 作用:定义常量,如八段数码表或是编程使用的常,在定义时加上code 或明确指明定义的常量保存到code memory(只读) 使用方法: char code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; 此关键字的使用方法等同于const data data memory (数据存储区)只能用于声明变量,不能用来声明函数,该区域位于片内,采用8位地址线编码

实验五

ε祈祈猫儿з 提交于 2019-12-15 19:49:16
// 练习:使用二分查找,在一组有序元素中查找数据项 // 形参是数组,实参是数组名 #include <stdio.h> #include <stdlib.h> const int N=5; int binarySearch(int x[], int n, int item); // 函数声明 int main() { int a[N]={2,7,19,45,66}; int i,index, key; printf("数组a中的数据:\n"); for(i=0;i<N;i++) printf("%d ",a[i]); printf("\n"); printf("输入待查找的数据项: "); scanf("%d", &key); // 调用函数binarySearch()在数组a中查找指定数据项item,并返回查找结果给index // 补足代码① // ××× index=binarySearch(a,N,key); if(index>=0) printf("%d在数组中,下标为%d\n", key, index); else printf("%d不在数组中\n", key); system("pause"); return 0; } //函数功能描述: //使用二分查找算法在数组x中查找特定值item,数组x大小为n // 如果找到,返回其下标 // 如果没找到,返回-1