按行读入

如果是string类型,则

string s;
getline(cin, s);

如果是C字符串类型,则

char str[256];
cin.getline(str, sizeof(str));
Last modification:November 7th, 2019 at 09:05 pm
如果觉得我的文章对你有用,请随意赞赏