String
(1)find()函数:
string s="sd12345fghjkjhgfdsdfghjoiuytrertyui";
string subs="12345";
int index=s.find(subs,0);
(2)c_str() c_str()是Borland封装的String类中的一个函数,它返回当前字符串的首字符地址。换种说法,c_str()函数返回一个指向正规C字符串的指针常量,内容与本string串相同。这是为了与C语言兼容,在C语言中没有string类型,故必须通过string类对象的成员函数c_str()把string对象转换成C中的字符串样式。
char *cstr, *p;
string str("Please split this phrase into tokens");
cstr = new char[str.size() + 1];
strcpy(cstr, str.c_str());
(3)atoi()、itoa() atoi(): 是C语言中的字符串转换成整型数的一个函数。函数原型如下:
int atoi(const char *nptr);
string intdata="123";
int data;
data=atoi(intdata.c_str());
itoa(): 函数有3个参数:第一个参数是要转换的数字,第二个参数是要写入转换结果的目标字符串,第三个参数是转移数字时所用的基数。在上例中,转换基数为10。10:十进制;2:二进制
3、to_string() 整数转字符串
int y=89;
string strv=to_string(y);
Vector
https://www.cnblogs.com/yskn/p/9053161.html
|