Trouble with curses
Gary Weimer
weimer at ssd.kodak.com
Thu Nov 8 06:41:54 AEST 1990
In article <20900012 at inmet> draper at inmet.inmet.com writes:
>
> switch(tolower(getch())) {
> /* I would watch out on the above line of code. tolower is a */
> /* macro that might have undesriable effects should the user */
> /* enter a character that is already in lower case. A good */
> /* thing to do would be check if the char was an upper case */
> /* using "isupper" before calling "tolower". */
ANSI complient definition of tolower() does call islower() before
making the conversion. In this case, the code "expands" to:
switch(islower(getch()) ? tolower(getch()) : (getch())) {
Note that you are now always making two calls to getch() (as someone
has already pointed out is a possibility).
More information about the Comp.lang.c
mailing list