From: Francis Glassborow <francis.glassbo...@btinternet.com>
Date: Thu, 13 Sep 2012 23:23:01 +0100
Local: Thurs, Sep 13 2012 6:23 pm
Subject: Re: understanding istream as a loop condition
On 13/09/2012 17:08, nvangogh wrote:
> In C++ primer 5th edition it says:You have had good answers to most of the problem, however control-d is
> "The input operator returns it's left operand, which in this case is
> "When we use an istream as a condition, the effect is to test the state
> while(std::cin >> value)
> With the above code, i can keep inputting ints - status will be 1 and
end of file for unix and its relatives. If you are using a windows
machine control-z is the end of file marker.
The reason control-d causes the above loop to terminate irrespective of
As others have said, if you do not ever try to extract any data from
> Now I was really impressed when I read this in Stroustrup as it looked
> I cannot understand how the above can work. In this case any input would
std::cin it cannot fail. Indeed all the key presses you might make might
never even reach the buffer std::cin is using and simply fill up the
keyboard buffer or some other buffer external to the program.
Things are deemed to be working until you do something to test them,
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.