Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!bu.edu!att!att!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Is there a good example of how toupper() works? Message-ID: <18683@haddock.ima.isc.com> Date: 31 Oct 90 05:41:14 GMT References: <2466@ux.acs.umn.edu> <15591@netcom.UUCP> Reply-To: karl@ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 19 In article <15591@netcom.UUCP> avery@netcom.UUCP (Avery Colter) writes: >Better to do something like: > while (*duh != NULL) Almost, but please don't spell it "NULL". This is traditionally used for the null pointer constant, which is not at all related to the null character (except that each is obtained by converting a constant zero to the appropriate type). On some systems the compiler won't accept the above, since the macro NULL is defined with pointer syntax. "while (*duh != '\0')" is better. >> *duh++; > >You gottit backwards, and dereferenced: ++duh; is what you want. You're right about the dereference being redundant, but the "backwards" bit is purely a style issue: "++duh" and "duh++" are exactly equivalent in this context, since the result of the expression isn't being used. Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint