在練習時用while(cin >> word),輸入時,嘗試用ctrl+c,enter, space都不可以結束輸入,最後經過google才知道用ctrl+z,之後再用Enter結束,以此記錄。
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
string word;
vector<string> text;
cout << "enter word:" << endl;
while (cin >> word)
{
text.push_back(word);
}
for (vector<string>::iterator iter = text.begin(); iter != text.end(); ++iter)
{
cout << *iter << endl;
}
system("PAUSE");
}