The comma after the last name is what makes it a bit more difficult. If there was no comma (just a space), you could just do:
If you must read it in with the comma coming after the last name, then you might have to use something like a delimiter. This will read all the characters until the delimiter is read in.
cin >> lastName;
cin >> firstName;
cout << firstName << " " << lastName << endl;
So, that should read all the characters into lastName until the comma is reached. I think the string method is something like:
cin.getline (lastName,256, ',')
Using a delimiter should work, although, there might be an easier method to implement. I'm sure another forum member will mention it if there is.
getline (cin,lastName, ',');