I used \"cin\" to read words from input stream, which like
int main( ){ string word; while (cin >> word){ //do sth on the input word
It helps me to terminate loop by hitting ENTER.
int main() { string word; while(getline(cin,word) && s.compare("\0") != 0) { //do sth on the input word } // perform some other operations }