Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!wuarchive!udel!rochester!kodak!ispd-newsserver!weimer From: weimer@ssd.kodak.com (Gary Weimer) Newsgroups: comp.lang.c Subject: Re: Trouble with curses Message-ID: <1990Nov7.194154.6071@ssd.kodak.com> Date: 7 Nov 90 19:41:54 GMT References: <173826@<1990Oct27> <20900012@inmet> Sender: news@ssd.kodak.com Organization: Eastman Kodak Lines: 16 In article <20900012@inmet> draper@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).