摘要: #include #include using namespace std;int main(){ string str; str.append("name-"); str.append("wangkaixun-"); str.append("id-"); ... 阅读全文
posted @ 2016-03-12 21:59 iucforever 阅读(523) 评论(0) 推荐(0) 编辑
摘要: 在某些情况下需要对输入的字符串进行处理,提取其中的需要的信息. 比如在linux中输入”mkdir test”,新建test文件夹,就需要提取其中的test字符. 提取的方法需要boost库中的函数,提取代码如下:#include #include #include #includ... 阅读全文
posted @ 2016-03-12 17:48 iucforever 阅读(2543) 评论(0) 推荐(0) 编辑
摘要: 之所以要对fgets自动添加的字符进行处理的原因之一是:当你想比较输入的字符时,你会发现输入的字符和源码用来进行对比的字符一模一样,但是使用strcmp比较时就是不一样,原因就是fgets对输入字符添加了一个字–符造成的.怎么造成的呢?strcmp会比较这个字符串所有的内容,长度都... 阅读全文
posted @ 2016-03-12 11:06 iucforever 阅读(1189) 评论(0) 推荐(0) 编辑
摘要: 最近写代码经常使用字符串,对于输入函数fgets网上有人说输入结束会在末尾自动添加’\n’,还有人说添加的是’\n’,我决定亲自验证:#include "iostream"#include "stdio.h"#include "stdio_ext.h"#include "stdli... 阅读全文
posted @ 2016-03-12 10:35 iucforever 阅读(3255) 评论(2) 推荐(1) 编辑
摘要: #include "iostream"#include "stdio.h"#include "stdio_ext.h"#include "stdlib.h"#include "string.h"using namespace std;int main(int argc, char ... 阅读全文
posted @ 2016-03-12 10:12 iucforever 阅读(1547) 评论(0) 推荐(0) 编辑