I used \"cin\" to read words from input stream, which like
int main( ){ string word; while (cin >> word){ //do sth on the input word
You can make a check for a special word in input. F.e. "stop":
int main( ){ string word; while (cin >> word){ if(word == "stop") break; //do sth on the input word } // perform some other operations }