标签:use min int system 添加 \n 字符 学习 string
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <list> #include <string> using namespace std; int main(int argc, char * argv[]) { //string str2 = "xiaoliang"; //string str3("xiaohei", 5); //string str4; //string str5 = ""; string str("xiaohong"); str.append("love"); str.append("youddddd",3);//只取前三个字符 str.append("overy",1,4); //从offset =1 开始连续添加四个字符; str.append(2,‘ ‘);//添加两个空格 const char * cstr = str.c_str(); // printf("%s\n",cstr); //考虑效率问题 string t1; t1.resize(1024); t1.clear(); t1.append("wei "); t1.append("you "); t1.append("qing"); string t2 = "hello"; t2[1] = ‘E‘; t2.at(2) = ‘L‘; string t4 = "yes"; if (t4 == "yes") { printf("相等\n"); } string t5 = "Liming is doing homework"; int num1 = t5.rfind("i"); system("pause"); return 0; }
标签:use min int system 添加 \n 字符 学习 string
原文地址:https://www.cnblogs.com/weiyouqing/p/9678136.html