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

Karl Heuer karl at haddock.ima.isc.com
Wed Oct 31 16:41:14 AEST 1990


In article <15591 at netcom.UUCP> avery at 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 at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list