#include <iostream>
#include <string>
using namespace std;
void main( ){
string first, last, full;
cout << "Enter your first name: ";
cin >> first;
cout << "Enter your last name: ";
cin >> last;
full = first + " " + last;
cout << "Hello, " << full << endl;
}
how do i make this work I keep getting errors
Firstly, it would be nice to hear some of the errors.
But from what i can tell, you are using cin to capture a string from user input.
you can't use cin for this purpose. The only alternative that I know of in iostream is to use cin.getline
http://www.cplusplus.com/reference/iostream/istream/getline/
you will need to have an array of chars instead of a string and convert the array into a string later, however.
Note, I may be incorrect here. I forget most of iostream
Last edited on
What errors are you getting?
It compiles and runs correctly for me using VS2010.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
Last edited on
thanks i solved the problem