Echoing chars and input functions

Karl Heuer karl at haddock.ima.isc.com
Fri Aug 19 02:38:12 AEST 1988


In article <2821 at boulder.Colorado.EDU> swarbric at tramp.Colorado.EDU (Frank Swarbrick) writes:
>In article <8349 at smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>>[The correct way to input a character, with echo when necessary, is]
>>	c = getchar();
>
>I could have sworn someone said their compiler did not echo the character when
>they used this.  Did I misunderstand someone, or is their compiler just
>non-conformant (broken)?

Since the compiler in question did echo when using fgets, it is indeed broken
according to the dpANS (which specifies that all I/O functions behave as if
they use getc/putc as primitives).

Now, it would be valid and conforming for the implementation to *never* echo.
There's nothing wrong with this; Unix programs generally do this if you've put
the terminal in noecho mode before starting the program.  But if this would
make C programs behave in a manner which is non-intuitive for the system in
question, then it's a poor quality implementation.  It's obvious that stdio
should use, as it's lowest-level primitive, whatever is the natural I/O
mechanism of the host.

No, the dpANS doesn't *force* this.  But, to paraphrase the Rationale, "It's
possible to create an implementation which conforms to the letter of the
Standard and yet is useless."

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list