开发者

How do you concatenate two strings? [duplicate]

开发者 https://www.devze.com 2023-04-06 22:56 出处:网络
This question already has answers here: Closed 1开发者_开发问答1 years ago. Possible Duplicate: How do I concatenate multiple C++ strings on one line?
This question already has answers here: Closed 1开发者_开发问答1 years ago.

Possible Duplicate:

How do I concatenate multiple C++ strings on one line?

How would I take:

string test1 = "Hello ";
string test2 = "World!";

and concatenate them to make one string?


How about

string test3 = test1 + test2;

Or maybe

test1.append(test2);


You could do this:

string test3 = test1 + test2;

Or if you want to add more string literals, then :

string test3 = test1 + test2 + " Bye bye World!"; //ok

or, if you want to add it in the beginning, then:

string test3 = "Bye bye World!" + test1 + test2; //ok
0

精彩评论

暂无评论...
验证码 换一张
取 消