How to concatenate two strings in C++
In this tutorial, we are going to learn about how to concatenate the two strings in C++.
Concatenation means the joining of two strings into a single string.
To concatenate the two strings into a single string, we can use the +
operator in C++.
Here is an example:
string a = "Welcome ";
string b = "John";
string c = a + b;
cout << c;
Output:
Welcome John
Similarly, we can use the built-in append() function in C++ to concatenate strings.
string a = "Welcome ";
string b = "John";
string c = a.append(b);
cout << c;
Output:
Welcome John