美文网首页
container-string-拼接

container-string-拼接

作者: 人不知QAQ | 来源:发表于2019-08-29 15:26 被阅读0次

#include<iostream>

using namespace std;

#include <string>

void  test01()

{

string str1;//默认构造

str1 = "我";

str1 += "爱玩游戏";

cout << str1 << endl;

str1 += ':';

cout << str1 << endl;

string str2;

str2 = "lol DNF";

str1 += str2;

cout << str1 << endl;

string str3 = "I";

str3.append("love");

cout << "str3=" << str3 << endl;

str3.append("game aaa", 4);

cout << "str3=" << str3 << endl;

str3.append(str2, 4, 3);//dnf

cout << "str3=" << str3 << endl;

}

int main()

{

test01();

system("pause");

return 0;

}

运行:

相关文章

网友评论

      本文标题:container-string-拼接

      本文链接:https://www.haomeiwen.com/subject/ocpiectx.html