赞
踩
代码:
string str1 = "this is a test";
char* c = "this is a test";
cout << "sizeof(str1):" << sizeof(str1) << endl; //28
cout << "sizeof(c):" << strlen(c) << endl; //14
cout << "str1.length():" << str1.length() << endl; //14
//字符串查找
string str2 = "www.baidu.com";
string str3 ="bai";
int wh=0;
wh = str2.find(str3); //返回下标
cout << "str2.find(str3) 查找到的字符在字符串中的位置是: " << wh << endl; //4
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。