string::empty

bool empty() const noexcept;
注:判断string对象是否为空,为空返回true

#include <iostream>
#include <string>

using namespace std;

int main()
{
string line;
string content;
cout << "enter line\n";
do{
getline(cin, line);
content += line + '\n';

}while(!line.empty());
cout << content;
}

posted @ 2019-12-24 09:07  MoonXu  阅读(242)  评论(0编辑  收藏  举报