take a look at the fllow program:
#include <iostream>
int main()
{
int sum=0,value;
while(std:cin>>value)
{
sum+=value;
}
std:cout<<"sum value is :"<<sum<<end;
reutnr 0;
}
The input operator return its left operand.The condition tests that result,meaning it tests std:cin.
When we use the iostream as a condition,the effect is to test the state of the stream. if the stream is valid,that is ,if it is still possible to read another input-then the test is successeds.
An istream becomes invalid when we hit end-of-file or encounter an invalid input,such as reading a value that is not an integer. An istream that is invalid state will cause the condition to fail.
Operating Systems uses different value for end-of-file.On Window Systems we enter a end-of-file by typing a control -z -simultaneousely type the "ctr" key and a "z".On Unix system ,includeing Mac -OS-X machines ,it is usually control-d.