getch() and getche() in MSC 4.0

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Oct 23 05:30:50 AEST 1988


In article <7594 at bloom-beacon.MIT.EDU> scs at adam.pika.mit.edu (Steve Summit) writes:
>If it is desirable for toupper to work correctly on characters
>that are nonalphabetic or already upper-case (I believe this
>property is called "idempotence," and as I said, it is a laudable
>goal), then the macro implementation has to be sacrificed, and
>toupper() made a proper function.

No, toupper() can be correctly implemented as a "safe" macro,
at least in an environment where all locales use character sets
that fit in 8-bit bytes.  Think about how other <ctype.h>
functions are typically implemented as safe macros and you
should be able to see how toupper() could be so done.



More information about the Comp.lang.c mailing list