Is there a good example of how toupper() works?

Dan Salomon salomon at ccu.umanitoba.ca
Thu Oct 18 05:07:01 AEST 1990


In article <wb76pN600awOE3SaQz at andrew.cmu.edu> jh4o+ at andrew.cmu.edu (Jeffrey T. Hutzelman) writes:
>Try this one:
>
>void strupper(char *str)
>{
>for (;*str!='\0';str++)
>	*str=toupper(*str);
>}

There is a problem with this solution on some systems.
Berkeley UNIX BSD 4.3 requires that the parameter of toupper
be a lowercase letter.  The result is undefined if it is not.
Therefore the test using islower may be necessary on some systems.
This makes toupper pretty useless in portable programs, but
those are the breaks.
-- 

Dan Salomon -- salomon at ccu.UManitoba.CA
               Dept. of Computer Science / University of Manitoba
	       Winnipeg, Manitoba  R3T 2N2 / (204) 275-6682



More information about the Comp.lang.c mailing list