I used \"cin\" to read words from input stream, which like
int main( ){ string word; while (cin >> word){ //do sth on the input word
Hit Ctrl-Z (Ctrl-D on *nix systems) and hit enter. That sends an EOF and invalidates the stream.