Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!topgun.dspo.gov!lanl!cmcl2!phri!marob!daveh From: daveh@marob.masa.com (Dave Hammond) Newsgroups: comp.lang.c Subject: toupper() side effects (was Re: evaluation order) Message-ID: <2511ADAD.6056@marob.masa.com> Date: 16 Sep 89 02:19:23 GMT Reply-To: daveh@marob.masa.com (Dave Hammond) Distribution: na Organization: ESCC, New York City Lines: 19 In article <9366@attctc.Dallas.TX.US> bobc@attctc.Dallas.TX.US writes: >[...] I figured that it would have been simpler to do something like > > while (((ch = toupper(getch())) != 'Y') && (ch !='N')); > Note that some implementations of toupper() (SunOS comes to mind) will return the wrong result if passed a non-lowercase argument. You'd probably want to expand this line and run an islower() test on the argument to toupper: int temp; while ( ((ch = (islower(temp=getch()) ? toupper(temp) : temp)) != 'Y') && (ch !='N')); -- Dave Hammond daveh@marob.masa.com