This post will discuss how to concatenate multiple strings in C++.

1. Using + operator

The most common approach to concatenate multiple strings in C++ is to use the + operator, which is overloaded for string objects.

Download  Run Code

Output:

Hello World

2. Using std::stringstream function

Another plausible way to concatenate multiple strings in C++ is to use string streams. The idea is to insert all individual strings into std::stringstream and then dump the buffer contents into a string using its str() function.

Download  Run Code

Output:

Hello World

3. Using std::string::append function

Finally, we can also use the string’s append() function that appends the specified string at the end of the string object.

Download  Run Code

Output:

Hello World

That’s all about concatenating multiple strings in C++.