我的程序假设输出 First Middle Last name 并忽略输入中的 , 。但是在我的程序中,逗号仍然在我的输出中,所以很明显我遗漏了一些东西。
#include <iostream>
#include <string>
using namespace std;
char chr;
int main()
{
string last, first, middle;
cout<< "Enter in this format your Last name comma First name Middle name."<<endl; //Input full name in required format
cin>>last; //receiving the input Last name
cin>>first; //receiving the input First name
cin>>middle; //receiving the input Middle name
cout<<first<<" "<<middle<< " " <<last; //Displaying the inputed information in the format First Middle Last name
cin.ignore(','); //ignoring the , that is not neccesary for the new format
cin>>chr;
return 0;
}