如何在一行上连接多个C ++字符串?
在这里,我们将看到如何在C++的一行中连接多个字符串。有几种不同的方法可以做到这一点。最简单的方法是使用加号(+)运算符。可以使用+连接字符串。我们可以在两个字符串之间放置+号,以使其串联。
Input: Some strings “str1”, “str2”, “str3” Output: Concatenated string “str1str2str3”
算法
Step 1: Take some strings Step 2: Concatenate them by placing + sign between them Step 3: Display the string Step 4: End
范例程式码
#include <iostream>
using namespace std;
int main() {
string str1, str2, str3;
str1 = "Hello";
str2 = "C++";
str3 = "World";
string res = str1 + str2 + str3;
cout << res;
}输出结果
HelloC++World
热门推荐
10 海鲜送礼祝福语简短大全
11 父亲简短结婚祝福语大全
12 新年发给客户祝福语简短
13 祝福语对联文案简短大气
14 人民子弟春节祝福语简短
15 祝贺新店开业祝福语简短
16 朋友药店开业祝福语简短
17 新年探亲祝福语简短精辟
18 2026祝福语简短创意牛