Combine Strings in C++

Combine Strings in C++

Download 11
Total Views 0
File Size 1.30 KB
File Type zip
Create Date May 9, 2016
Last Updated May 9, 2016

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;



Leave a Reply

Your email address will not be published. Required fields are marked *


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