Consider the following code
int main(){ int sum = 0, value = 0; while (std::cin >> value) sum += value; std::cout << "sum is: " << sum << std::endl; return 0; } What is the return value of >> operator, against which while loop is evaluated ? The program terminates on EOF input (Ctrl+Z for windows). Does that mean 0 is stored to cin in case of an EOF ? Does it have anything to do with ASCII value of EOF ?
std::istream&, but this question is a duplicate.stringstreamorcindoes not matter, answer holds for allstd::istreams.