why string doesn't read my end of file ?

i have a question, i'm studyng the string library type and i have to write this program :

1
2
3
4
std::string word; 
while (std::cin >> word) {
std::cout << word << std::endl; 
}


why if my input is :

hi my name is ^Z

the output is :

hi
my
name
is

why the program doesn't fall out from the while loop ?
why my program does not recognize my sequence of end of file ?




The terminals that I do use, don't have ^Z as EOF.

Try this. Write the input into a text file. Then use redirection:
foo.exe < data.txt

"foo.exe" is your program and "data.txt" is the text file. File has an end.
Topic archived. No new replies allowed.