Krist
03-28-2001, 05:55 AM
I'm trying to detect if a stream is getting its stadnard input from the console
(i.e. if it is waiting indefinitely for a user to type something) in a console
application. Then, I can use this detection to generate some error.
To achieve this, I used the following function
istream myStream(cin);
streamsize charsAvailable = myStream.rdbuf()->in_avail()
if this call returns a result > 0, then there are characters available in
the input buffer.
unfortunately, if the result of this call is 0, one is not guaranteed that
cin.get() will NOT have a char available
Does anyone know a better solution (using the istream object ?)
(i.e. if it is waiting indefinitely for a user to type something) in a console
application. Then, I can use this detection to generate some error.
To achieve this, I used the following function
istream myStream(cin);
streamsize charsAvailable = myStream.rdbuf()->in_avail()
if this call returns a result > 0, then there are characters available in
the input buffer.
unfortunately, if the result of this call is 0, one is not guaranteed that
cin.get() will NOT have a char available
Does anyone know a better solution (using the istream object ?)