书上看到这个示例:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string buf;
while (cin >> buf && !buf.empty())
cout << 1;
}
我想问!buf.empty()
有必要吗?,据我的理解,cin>>buf
不接受空白字符,那就肯定不是空字符串了,所以while(cin>>buf)
就行了.
黄舟2017-04-17 12:07:21
][1]
In fact, there is no need to add spaces. By default, spaces and line breaks are not accepted