Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!mailrus!ames!haven!umd5!gsmith From: gsmith@umd5.umd.edu (Gordon Smith) Newsgroups: comp.lang.c Subject: Re: getch() and getche() in MSC 4.0 Keywords: *##%@^!&ing functions! Message-ID: <4166@umd5.umd.edu> Date: 24 Oct 88 01:56:30 GMT References: <10508@dartvax.Dartmouth.EDU> Reply-To: gsmith@umd5.umd.edu (Gordon Smith) Distribution: comp.lang.c Organization: University of Maryland, College Park Lines: 18 In article <10508@dartvax.Dartmouth.EDU> jalphin@prism.clemson.edu writes: > > [This article was written by Scott Horne, not Yaping Xu. > >Has anyone else had trouble with getch() and getche() in Microsoft C v. 4.0? >They often skip every other keypress on me--and in one case, they skip two >keypresses out of three! Maybe it's my code. This occurs mainly when I try > > c = toupper(getch()); > The reason your program is not working correctly, is because of the toupper, not the getch. toupper() is implemented as a macro, not a function. Therefore the code MAY look similiar to this: c = isalpha(getch()) && isupper(getch()) ? getch() : getch()-'a'+'A'; Therefore executing getch() more than once. This may not be the exact macro description for toupper, but it does illustrate the point.