vector<string> svec;
string str;
while (cin >> str&&!cin.eof())
{
svec.push_back(str);
}
for (auto c:svec)
{
cout << c << " ";
}
If I input tt tt tt
,the output is tt tt tt
.
But if i input nothing ,i type Ctrl+Z ( windows + vs2013)will crash.
So i try to fix it.
while (!cin.eof())
{
cin >> str;
svec.push_back(str);
}
Now , if i input nothing , I type Ctrl+Z will not crash.
But if i input tt tt tt
,the output is tt tt tt tt
.
Now I don't know how to fix it. Please help me .