【发布时间】:2019-07-12 10:09:14
【问题描述】:
我是 C++ 新手,发现很难使用字符串。用户正在输入他的全名,即用空格分隔的名字和姓氏,我想在他输入他的名字时将其存储在不同的字符串中
输入
ABC XYZ
代码
string s1,s2;
getline(cin,s1);
getline(cin,s2);
cout<<"Firstname :"<<s1<<endl;
cout<<"Lastname :"<<s2<<endl;
输出
Firstname :ABC XYZ
Lastname : //nothing is printed here , i want to sore the last name here
【问题讨论】: