I have to write a program that inputs a name from a user; last, first, middle and output it first middle last. Do I have to use cout<<"Enter your name last, first middle name"; is that how I get the input to that format?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <string>
usingnamespace std;
char chr;
int main()
{
char first, middle, last;
cout<< "Enter your last name, first name and middle name"<<endl;
cin.get(last);
cin.get(middle);
cin.get(first);
cout<<first<<middle<<last;
cin.ignore(',');
cin>>chr;
return 0;
}
I know that this doesn't work correctly and I am probably missing a lot but I am new and I just need some guidance. Thank you
I have tried moving the cin.ignore to between the cinlast and first also before the cin>>last and my output doesn't display. Also changed to cin.ignore(100,',');