Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!xylogics!transfer!crackers!m2c!wpi.WPI.EDU!profesor From: profesor@wpi.WPI.EDU (Matthew E Cross) Newsgroups: comp.lang.c Subject: Re: Is there a good example of how toupper() works? Message-ID: <1990Oct17.170914.683@wpi.WPI.EDU> Date: 17 Oct 90 17:09:14 GMT References: <2466@ux.acs.umn.edu> Organization: Worcester Polytechnic Institute Lines: 24 In article jh4o+@andrew.cmu.edu (Jeffrey T. Hutzelman) writes: >Try this one: > >void strupper(char *str) >{ >for (;*str!='\0';str++) > *str=toupper(*str); >} Nope, won't work - the return value of 'toupper' is undefined if the input is not a lowercase character. Try: void strupper(char *str) { for (;*str!='\0';str++) *str=islower(*str)?toupper(*str):*str; } (I hope I got the '? :' syntax right...) -- +----------------------------------------------------+------------------------+ | "The letter U has a lot of uses ... | Looking for | profesor@wpi.wpi.edu | | I like to play it like a guitar!" | suggestions +------------------------+ | -Sesame Street | for new gweepco programs... |