On Wed, 4 Jan 2006 22:05:43 UTC,
or*****@gmail.com wrote:
rayw wrote: Not quite sure I've got this right, but you're asking [?] if I've read
stdin - until it's empty, how can I then determine whether something else is
waiting there to be read?
Well, I guess you'd try to read something from stdin
My problem is that I need to read from stdin only if is something to
read, i don want to break the program until somebody type something...
Impossible mission. There is nothing in standard C that defines that
stdin is a device that will do what you thinks. stdin may return data
until EOF is reached and nothing else thereafter or it may block the
program until some new data arrives from anywhere it is bounded to or
it may behave something else depending on the API you uses to read
from stdin. It may even change its behavior from run to run depending
on the device or file stdin is bounded to.
C knows nothing about keyboards, punch cards, files, or other devices.
stdin is simply an abstract stream that will serve a stream of
characters until EOF is reached.
When you really needs a specific behavior check the documentation of
the system your program is running under and look if (or if not) that
specific system gives you an API that does what you asks for.
--
Tschau/Bye
Herbert
Visit
http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!