学点 C 语言(3): 转义字符\n //换行 \r //回车 \b //退格 \f //换页 \t //水平制表符 \v //垂直制表符 \a //响声 \" //双引号 \' //单引号 \x?? //用小写 x 和两位数字(十六进制数)表示一个字符 \??? //用三位数字(八进制)表示一个字符 例1:#inclu...
C语言的操作符号#include <iostream> int main(void) { int a = 100, b = 40; //理解++在前还后的区别; a = b++; //a = b ; b= b+1; //a = ++b; //b = b+1; a = b; std::cout << a <<...
1.分割字符串:strtok()2.合并字符串:strcat()3.复制字符串:strcpy()4.查找字符串:strstr()5.查找字符串中指定字符:strchr()1.分割字符串:strtok()函数原型: char strtok(char s,char *delims)参数:s:表示字符指针,此指针应当指向一串字符串。或者 s 可以等于 NULL,s = NULL则表示用于保存字符...
头文件:#include<time.h>strftime()函数函数原型:size_t strftime(char array,size_t maxsize,const char format,const struct tm *tmptr);参数:1.array:为字符型数组名2.maxsize:为array数组的大小3.format:为要打印的参数,下面给出列表4.tmprt ...
includeincludeusing namespace std;void get_size(ifstream &in){long b,e; b=in.tellg(); in.seekg(0,ios::end); e=tellg(); long size=e-b; cout<<"size="<<size<<endl;}int main...
C++扫描目录下文件,可以根据后缀名扫描,可以用通配符的方式扫描,可以显示文件属性(只读,隐藏,类型等)。 所用函数: long _findfirst( char *filespec, struct _finddata_t *fileinfo ); 代码示例: #include<iostream> #include<io.h> using n...
1、cin2、cin.get()3、cin.getline()4、getline()5、gets()6、getchar()1.cin>>用法1:最基本,也是最常用的用法,输入一个数字:include using namespace std;main (){int a,b;cin>>a>>b;cout<<a+b<<endl;}输入:2...
'\n' 换行,光标移到下一行的开头;'\r' 回车,光标移到当前行的开头,不会换到下一行,如果接着输出的话,本行以前的内容会被逐一覆盖;#include <iostream> using namespace std; int main() { cout << "this is the first line\n"; ...
1、strcmp:字符串比较if (strcmp(pOpt, "HASH") == 0)0:相同大于0:字符串1大于字符串2小于0:字符串1小于字符串22、memset:清空结构体memset(&stTest,0,sizeof(struct sample_struct));如果是数组:struct sample_struct TEST[10];则memset(TEST,0,sizeof(st...
使用strtok# include <string.h> # include <stdio.h> void split(char *src,const char *separator,char **dest,int *num) { /* src 源字符串的首地址(buf的地址) separator 指定的分割字符 ...