Here we will see how to concatenate multiple strings in one line in C++. There are few different methods to do that. The easiest method is by using the plus (+) operator. The strings can be concatenated using +. We can place + sign between two strings to make them concatenated.
Input: Some strings “str1”, “str2”, “str3” Output: Concatenated string “str1str2str3”
Algorithm
Step 1: Take some strings Step 2: Concatenate them by placing + sign between them Step 3: Display the string Step 4: End
Example Code
#include <iostream>
using namespace std;
int main() {
string str1, str2, str3;
str1 = "Hello";
str2 = "C++";
str3 = "World";
string res = str1 + str2 + str3;
cout << res;
}Output
HelloC++World