Path: utzoo!attcan!uunet!munnari.oz.au!metro!wolfen!hls0!george From: george@hls0.hls.oz (George Turczynski) Newsgroups: comp.lang.c Subject: Re: Is there a good example of how toupper() works? Message-ID: <949@hls0.hls.oz> Date: 23 Oct 90 23:29:52 GMT References: <2466@ux.acs.umn.edu> Lines: 48 In article <2466@ux.acs.umn.edu>, edh@ux.acs.umn.edu (Eric "The Mentat Philosopher" Hendrickson) writes: > Basically, what I want to do is take a string of upper/lower case, and make > it all upper case. Here is a first try at it, > > [Code deleted] > > Can anybody point out a good way of doing this? Since people have already commented on the oversights (?) in your code, I won't add any more. So here's a piece of code that does the trick, but is perhaps best implemented as a function: /* --- Cut here --- */ #include #include main() { char *work, *duh= "Hello"; printf("%s\n",duh); /* The important piece follows... */ for( work= duh; *work; work++ ) if( islower(*work) ) *work= toupper(*work); /* That was it ! */ printf("%s.\n",duh); exit(0); } /* --- Cut here --- */ I hope that this might help you to solve your problem. Have a good day... -- George P. J. Turczynski, Computer Systems Engineer. Highland Logic Pty Ltd. ACSnet: george@highland.oz |^^^^^^^^^^^^^^^^^^^^^^^^| Suite 1, 348-354 Argyle St Phone: +61 48 683490 | Witty remarks are as | Moss Vale, NSW. 2577 Fax: +61 48 683474 | hard to come by as is | Australia. --------------------------- space to put them ! ---------------------------