Andrew wrote:
Hello,
I have read about stdin and stdout being standard input and output
streams, but I am still having trouble visualizing how they really
work and what they contain during program execution. For instance
could you use a call to fputc() and/or fseek to write a carriage
return to stdin and cause a subsequent call to getchar() to return
without the user pressing a return key? I have checked the C FAQ and
GNU C Library section on standard streams for more info and found a
lot on their usage, but not much on the internals of how they are
structured and operate. Thanks for any advice.
stdin is an input stream, hence output operations are
not meaningful[*]. Dually, stdout and stderr are output
streams, so input operations aren't usable. fseek() and
other positioning functions may or may not work, and this
may vary from one program execution to the next.
The C Standard describes what an implementation may and
must do, but not how it is to be done. P.J. Plauger's "The
Standard C Library" considers many of the issues facing a C
library implementor and exhibits a specimen implementation,
but its internals may have little resemblance to those of
the system(s) you're familiar with.
[*] ungetc() is an "output-like" operation, in a very
limited way. It will do what you're asking for,
but not what I suspect you desire.
--
Er*********@sun.com