随笔分类 -  C++

sizeof string
摘要:char a[] = "hello";string s = "hello";cout<<sizeof(a)<<endl;cout<<sizeof(s)<<endl;cout<<sizeof(s.c_str())<<endl; 输出为6324最后一个c_str返回的是char*,所有指针的长度都为4... 阅读全文

posted @ 2014-06-06 16:09 Sara Chi 阅读(357) 评论(0) 推荐(0)

算术类型&确定编译环境的位数
摘要:算术类型:整型(integral type)char : 一个机器字节(1BYTE = 8BIT)bool: 1 BIT整型: int: 与编译环境相关(不是机器),32位的编辑环境则长度为32BIT,故可以使用sizeof(int)来得到编译器环境的位数(返回的是字节长度)short/long/... 阅读全文

posted @ 2014-06-06 15:44 Sara Chi 阅读(150) 评论(0) 推荐(0)

cerr cout clog及文件重定向
摘要:cout:标准输出,输出到缓冲区中,需要使用endl(将缓冲区内容刷新到设备中,并换行) 可以被重定向输出到文件中。cerr:标准错误流,直接输出到显示屏,无缓冲clog: 标准错误流,输入到缓冲区重定向到文件的方法:1. 编译运行时重定向test.exe>>test.txt;2.int a = ... 阅读全文

posted @ 2014-06-06 14:51 Sara Chi 阅读(495) 评论(0) 推荐(0)

vector<string> split(string &str, const char *c); & string小结
只有注册用户登录后才能阅读该文。

posted @ 2014-05-21 20:41 Sara Chi 阅读(12) 评论(0) 推荐(0)