Hi! This is my first string function encercise ever so I'm teaching myself this. Here is the excercise
Write a program that asks for a user first name and last name separately.
The program must then store the users full name inside a single string and out put it to the string.
i.e.
Input:
John
Smith
Output:
John Smith
I'm trying to make a construct a string object and store two seperate strings within that and output them as one. I'm having difficulties lol! I'd appreciate anyone's help! Thanks and Happy new years!
// Strings are your friends.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
usingnamespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string first_name, last_name;
cout << "Please enter your first name.\n";
cin >> first_name;
cout << "Please enter your last name.\n";
cin >> last_name;
string(first_name, last_name);
cout << string(first_name, last_name);
return 0;
}
#include <iostream>
#include <string>
usingnamespace std;
int main(){
//Initialize are vvery important
string firstname = "";
string lastname = "";
cout << "Enter First Name : ";
cin >> firstname;
cout << "Enter Last Name : ";
cin >> lastname;
//String object that store another two string object
string Name = firstname + lastname;
cout << "The Name is : " << Name << endl;
system( "pause" );
return 0;
}