[code]#include
by lambert_fan - C/C++ - 2011-02-24 13:27:34 阅读(3047) 回复(12)
今日终于得闲,不用读fucking algorithm,study shit data structure!!!那就看看string吧,其实string以前写过,奈何这种东东基本上不用时隔多久就会忘掉忘掉的!!!注明下我这里这个string.c是lib/string.c下的, stupid library routines.. The optimized versions should generally be found as inline code in !!! 但是只有这个stupid library才是我所懂的,optimized versions全是汇编,想看自己去看了,在下是不会汇编的!!! ...
之所以抛弃char*的字符串而选用c++标准程序库中的string类,是因为他和前者比较起来,不必 担心内存是否足够、字符串长度等等,而且作为一个类出现,他集成的操作函数足以完成我们大多数情况下(甚至是100%)的需要。我们可以用 = 进行赋值操作,== 进行比较,+ 做串联(是不是很简单?)。我们尽可以把它看成是c++的基本数据类型。 好了,进入正题……… 首先,为了在我们的程序中使用string类型,我们必须包含头文件 。如下: ...
发现这样代码: test.h std::string test(std::string param); test.c string test(string param) { string ipaddr,port,option; string ret; if(param.find_first_not_of("1234567890")!=string::npos){ string errs = "数据类型错误"; ret = formaterrmsg(errs); return ret; } vector<string> cmd; return ret; }...
张三,3456123, 湖南 | 李四,4564234, 湖北|王小二, 4433253, 北京| 。。。 请以 "|" ","为分隔符,同时又要过滤空格,把每行分成相应的字段 用string实现,help!谢谢各位
问题源自于c++primer中的一道习题
疑问1:p78 练习题3.9 和 书上关于string下标的说法貌似有矛盾?
书上:如果string 不为空的话, 那么s[0]就是其第一个字符,s[s.size() - 1] 就是其最后一个字符.
但是 练习题 中的string 为空,长度为0 , 然而 cout << s[0] 或是 cout << s[1] 竟然没有出错!编译通过且运行无错!
程序:
#include <string>
#include
各位大侠,能不能帮忙看看我的这个程序哪里有问题。 运行没有错误,也可以连接到mysql,但就是不能把数据从mysql中调出。 我是新手,但是我的直觉告诉我,是在什么地方把命令的顺序搞错了。 还希望各位前辈多费心指点一下。 //---------------代码 sql::Driver *driver; sql::connection *con; sql::Statement *stmt; sql::ResultSet *res; /* create a connection */ driver = get_driver_instance(); con = driver->connect("lo...
[quote]
#include
我用微软的Vc++6.0学习c++,请问怎么使用string型变量?
我写的一段代码:
#include
c++ string: How to convert between 'cstring' and 'std::string'? 'cstring' to 'std::string': std::string cannot always construct from a LPcTSTR i.e. the code will fail for UNIcODE builds. So the following conversion will lead to error: cstring cs("Hello"); std::string s((LPcTSTR)cs); As std::string can construct only from LPSTR / LPcSTR, a programmer who uses Vc++ 7.x or better can utilize conver...
代码1:[code]#include