//字符串
char pp[] = "Hello World"; //容器
string pps1 = "Hello World";
string pps2 = "Hello World";
string s = pps1 + pps2;
//字符串的函数
for (string::iterator It = pps1.begin(); It != pps1.end(); It++)
{
cout << *It << endl;
}
int ssize = pps1.size(); //获取容器字符串数量 char
int slength = pps1.length(); //获取大小
int smaxsize = pps1.max_size(); //最大尺寸
int scapacity = pps1.capacity(); //预分配
int bEmpty = pps1.empty(); //判断是否为空
pps1.c_str(); //将字符串最原始数据暴漏
pps1.data(); //内存地址
pps1.reserve(1024); //预分配多少空间
string hellos = "ooo";
pps1.swap(hellos);
char newstring[] = "oooo";
pps1.insert(2, newstring);
pps1.append(hellos);
//pps1 += hellos;
char cchar = 'p';
pps1.push_back(cchar);
pps1.erase(5); //指定清除区域
pps1.clear(); //全部清除
pps1 = "NewString sda";
pps1.assign("Newstring dsawwww");
char arraychar[] = "Newstring";
char arraychar2[] = "CCCCCCC";
string Hello = pps1.replace(0,strlen(arraychar),arraychar2);
pps1.copy(arraychar, strlen(arraychar) - 3);
char ppcc[] = "CC";
int pos1 = pps1.find(ppcc);
char pos1char = pps1[pos1];
int pos2 = pps1.rfind(ppcc);
char pos1char1 = pps1[pos2];
pos1 = pps1.find_first_of(ppcc); //返回第一个
pos2 = pps1.find_last_of(ppcc);
pos1 = pps1.find_first_not_of(ppcc); //不存在的
pos2 = pps1.find_last_not_of(ppcc);
string cccc = pps1.substr(2, 5); //字符串切割
pps1.compare(ppcc); //比较