摘要: // string::substr#include <iostream>#include <string>using namespace std;int main (){ string str="We think in generalities : but we live i:n\bdd\etails."; // quoting Alfred N. Whitehead string str2, str3; size_t pos; size_t pos1; //str2 = str.substr (12,12); // "gene... 阅读全文
posted @ 2012-07-05 01:19 dengyigod 阅读(101) 评论(0) 推荐(0) 编辑
摘要: http://zhidao.baidu.com/question/213056154 阅读全文
posted @ 2012-07-05 01:18 dengyigod 阅读(95) 评论(0) 推荐(0) 编辑
摘要: http://www.cplusplus.com/reference/string/string/find_last_of/ 阅读全文
posted @ 2012-07-05 01:08 dengyigod 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 由于行长度和文本文件行数均未知,相当于二维 char 数组的两维长度都未定义。由于getline函数可以自动扩充 char 数组长度,我最初的想法是使用 getline 得到每行,然后每次对 char ** 进行 realloc,直到读完整个文件。但是这种做法并不好,首先 getline 是 glibc 的扩展,而不是 C 语言的标准函数,使用除 gcc 以外的编译器是不一定能编译通过的;其次,每次对 char ** 指针进行 realloc 显得代码很 ugly。可以使用 fgets 替代 getline,但是就要自己来控制一维 char 数组的长度。后来想想,换了一种思路,首先将整个文件读 阅读全文
posted @ 2012-07-05 00:18 dengyigod 阅读(110) 评论(0) 推荐(0) 编辑