c programming style
Chris Torek
chris at umcp-cs.UUCP
Tue Jul 16 14:13:25 AEST 1985
> Say we have some item like:
> main(argc, argv)
> int argc;
> char **argv;
> stepping through the array of pointers can be done by by incrementing
> a pointer:
> argv++;
> This will get us to the next pointer....
> argv = argv + 1;
> will NOT (unless by the happy happinstance that a pointer is exactly
> the same size as a character!)
Nope. In this case ``argv = argv + 1'' will get you to the next
pointer, just like ``argv++''. See any C book, ``pointer arithmetic''.
The form ``lvalue += 1'' is always equivalent to ``++lvalue''
(though many compilers will generate different code for the two).
Furthermore, ``lvalue++'' is equivalent to ``++lvalue'' iff the
value of the expression is not used. (Again, some compilers---not
many---may generate different code.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP: seismo!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at maryland
More information about the Comp.lang.c
mailing list