Skip to main content
gamedev.net
🔒 Locked

Checking if a stream i empty..

Started by alberto_balsalm Dec 5, 2001 at 3:48 PM 0 replies 250+ views
Original Post
alberto_balsalm
alberto_balsalm
if i type a text stream in the consol and the starts to read (cin) every word seperately.. how to i check if the stream is empty? i tried cin.eof() but that didn''t seem to work...
Fruny
Fruny
eof() is only set AFTER a read.
You can try


if( cin.peek() == EOF ) ... // or more exactly istream::traits::eof();


Edited by - Fruny on December 5, 2001 4:55:25 PM
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.