Combine Strings in C++

Combine Strings in C++

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

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;
}

Comments

comments

Leave a Reply

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

*