ANSI C and standard libraries

Karl Heuer karl at haddock.ISC.COM
Tue Aug 2 00:25:21 AEST 1988


In article <62114 at sun.uucp> swilson%thetone at Sun.COM (Scott Wilson) writes:
>[On some deficient OS and/or C library, getchar() doesn't echo or allow
>backspacing.  Also scanf has the same problem.]
>
>(The way I solved this particular problem in LSC was to #undef
>getchar, define it be "realgetc", and write realgetc to behave
>like I thought it should.

So getchar() was a macro?  I bet your solution didn't solve the scanf()
problem, then, unless you recompiled.

>Writing realgetc was easy because fgets does echo characters and allow
>character erase, so I would just fill a buffer with fgets and hand out one
>character at a time when realgetc was called.)

Now this *is* in violation of the Standard.  All of the I/O functions are
supposed to behave as if by repeated calls to fgetc/fputc.  Echo and erase
should either be enabled in getchar(), or disabled in fgets().

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



More information about the Comp.std.c mailing list