Combine Strings in C++

Download
Download is available until [expire_date]
  • Version
  • Download 25
  • File Size 1.30 KB
  • File Count 1
  • Create Date May 9, 2016
  • Last Updated May 9, 2016

Combine Strings in C++

Combine Strings in C++

Concatenation is a proper term for combining two or more strings. This c++ program will ask the user to enter a firstname and lastname, the output will be the combination the firstname and lastname. The operator used to combine two strings is the plus sign “+”.

Source code:

#include < iostream >

using namespace std;

int main()
{
    const string space = " ";
    string firstname, lastname;
    cout << "Enter Firstname:" << endl;
    cin >> firstname;
    cout << "Enter Lastname:" << endl;
    cin >> lastname;
    cout <<"Your Fullname: " << firstname + space + lastname << endl;

    return 0;
}
, , , , , ,

Post navigation

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.