🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to C++ Notes
Topic #30

Concatenation


String Concatenation

The + operator can be used between strings to add them together to make a new string. This is called concatenation:

Example

  string firstName = "John ";
string lastName = "Doe";
string fullName =
  firstName + lastName;
cout << fullName;

In the example above, we added a space after firstName to create a space between John and Doe on output. However, you could also add a space with quotes (" " or ' '):

Example

  string firstName = "John";
string lastName = "Doe";
string fullName =
  firstName + " " + lastName;
cout << fullName;

Append

A string in C++ is actually an object, which contain functions that can perform certain operations on strings. For example, you can also concatenate strings with the append() function:

Example

  string firstName = "John ";
string lastName = "Doe";
string fullName =
  firstName.append(lastName);
cout << fullName;

Tip: A list of other useful string functions, can be found in our String Functions Reference.

Want to go beyond the notes?

Join CodingNow 2.0's C++ course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Concatenation – FAQs

Quick answers about learning Concatenation in C++.

This free note from CodingNow 2.0 explains Concatenation in C++ — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C++ topic on CodingNow 2.0, including Concatenation, is 100% free with no signup required.
With focused practice, most students grasp Concatenation in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now