C++ 提高教程 STL -string字符串拼接

 

# include<iostream>
# include<string>
using namespace std;

//string字符串拼接
void test01()
{
	string str1 = "我";
	str1 += "爱玩游戏";
	cout << str1<< endl;
	str1 += ":";
	cout << "str1 =" << str1 << endl;
	string str2 = "LOL DNF";
	str1 += str2;
	cout << "str1 =" << str1 << endl;


	string str3 = "I";
	str3.append(" Love");
	str3.append(" Game abcde",5);
	cout << "str3 =" << str3 << endl;
	str3.append(str2);
	cout << "str3 =" << str3 << endl;
	str3.append(str2,4,3);
	cout << "str3 =" << str3 << endl;


}

int main()
{
	test01();
	system("pause");
	return 0;
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
10-04 05:12
瑞雪兆丰年_:可以贴个超级大的校徽,以防HR眼拙
点赞 评论 收藏
分享
牛客96763241...:杭电✌️也是打完招呼,没人回吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务