ChinaUnix.net
相关文章推荐:

stl 字符串比较

[code]void Rand2Stand(char* strTest,vector;* words) { char* p = strTest; char sepword[64]="\0"; int i=0; int j=0; int nLen = strlen(strTest); BOOL bTrue = FALSE; while(TRUE) { if(*p == ' ' || *p == '\t') { if(bTrue) { words->;push_back(sepword); j=0; memset(sepword,0,64); } bTrue = FALSE; p++; continue; }else bTrue = TRUE; sepword[j++] = *p;...

by toxyboy - C/C++ - 2005-03-31 11:35:09 阅读(2335) 回复(7)

相关讨论

如题,stl中我们经常有这样的用法 vector ... ... sort(v.begin,v.end,greater_than) 其他的algorithm函数用法类似 我有一两个个问题: (1)greater_than作为一个类,在sort内部生成对象了吗? 如果没有生成对象,它的operator()(const T&t1 const T&t2)也不是静态函数,如何能够被调用? (2)如果我们不用比较谓词,而是用一个函数传入,像 bool cmp( int a, int b ) { return a > b; }也可以。 显然,不需要为cmp生成...

by jeanlove - C/C++ - 2009-02-06 10:49:22 阅读(2218) 回复(4)

[code]#include #include #include #include #include #include using namespace std; int main(int argc, char *argv[]) { ifstream infile("word.txt",ios::in); if(!infile) { cout<<"Unable to open the necessary file"< is(infile); istream_iterator eof; vector text; cop...

by sysabod - C/C++ - 2009-03-29 22:19:10 阅读(1929) 回复(5)

或着能不能直接找到字符串中第n个分割符所在的位置? [ 本帖最后由 guowei_78 于 2006-4-20 17:21 编辑 ]

by guowei_78 - C/C++ - 2006-04-20 17:45:06 阅读(1371) 回复(2)

stl序列容器vector, deque, list使用箴言: 1.只添加或删除序列尾部的元素时,vector的效率是很高的。可以在vector的开头和中间插入元素,但其效率相当低。因为要移动插入点以后的所有元素并在自由存储区分配一个新内存区域。从开头和中间删除元素也比较慢,因为也要移动元素。 2.在序列容器的中间添加和删除元素应该使用list容器。实际上,使用list容器可以在序列的任意位置高效的插入元素而无需移动已有元素,删除list中的元素也...

by ouukuu - Solaris文档中心 - 2009-09-19 05:52:25 阅读(1754) 回复(0)

class toLower { public: char operator() ( char str) { char ch = tolower(str); return ch; } }; int main() { string str = "abABcd"; transform(str.begin(), str.end(), str.begin(), toLower()); for (string::iterator iter=str.begin(); iter != str.end(); iter++) cout << *iter; return 0; }这...

by hr_it - C/C++ - 2008-10-14 14:19:54 阅读(1005) 回复(6)

新建个stl研究的群,希望感兴趣的加入,大家一起探讨。 37746921 高手新手都来啊。 [ 本帖最后由 Nopro 于 2009-3-21 18:26 编辑 ]

by Nopro - C/C++ - 2009-03-21 17:46:09 阅读(531) 回复(2)

前言 It came without ribbons! It came without tags! It came without packages, boxes or bags! ——Dr. Seuss, How the Grinch Stole Christmas!, Random House, 1957 我第一次写关于标准模板库的东西是在1995年,那时我决定把《More Effective C++》的最后一个条款写成一 个stl的简要概览。我早该更好地了解stl。不久以后,我开始收到一些邮件,问我什么时候写《Effective stl》。 我把这个想法忍了几年。一开始,...

by haoji - IT图书与评论 - 2008-06-05 17:40:41 阅读(25226) 回复(239)

学习stl有一个困惑,那位精通stl的人能说一下,stl源文件的结构,如果要阅读stl文件,应该按照什么迅速来,先看那些代码,在看哪些代码。 看了不少了,感觉很乱!!! 烦熟悉的人整理一下! 不胜感激!

by vincol - C/C++ - 2007-09-18 02:02:18 阅读(1399) 回复(5)

看过stl的string了没有? 你们说它直接些个类不就行了,为什么要搞一个什么char_traits来做什么,我看过别的公司写的自己的库,其中就有直接一个类实现的。你们说它搞的那么麻烦搞什么?有人说这种设计是“使用模板过渡了”,反正我看起来就很反感!

by vincol - C/C++ - 2007-09-15 23:15:11 阅读(1199) 回复(2)

最近学习stl,但是编译总是报错,我想问一下用stl编写的代码在linux底下怎么编译?需要哪些库文件,已经头文件路径,贴上代码和错误: #include #include #include int main(int argc,char* argv[]) { list szlist; list::iterator pszlist; szlist.push_back("i"); szlist.push_back("am"); szlist.push_back("zengxi"); if(szlist.empty(...

by ancientlegend - C/C++ - 2007-01-11 15:57:17 阅读(489) 回复(3)