Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!wuarchive!emory!hubcap!svissag From: svissag@hubcap.clemson.edu (Steve L Vissage II) Newsgroups: comp.lang.c Subject: Re: Is there a good example of how toupper() works? Message-ID: <11021@hubcap.clemson.edu> Date: 18 Oct 90 15:29:54 GMT References: <1990Oct17.170914.683@wpi.WPI.EDU> Organization: Clemson University, Clemson, SC Lines: 19 From article <1990Oct17.170914.683@wpi.WPI.EDU>, by profesor@wpi.WPI.EDU (Matthew E Cross): > Nope, won't work - the return value of 'toupper' is undefined if the input is > not a lowercase character. So define your own toupper() macro. That's what I did. #define toupper(ch) ((ch<123 && ch>96) ? ch-32 : ch) You don't even have to do any casts, because C is pretty free with it's int<->char conversions. > void strupper(char *str) > { > for (;*str!='\0';str++) > *str=islower(*str)?toupper(*str):*str; > } ^ | *str=toupper(*str); Steve L Vissage II