c programming style

rdp at teddy.UUCP rdp at teddy.UUCP
Tue Jul 16 03:02:42 AEST 1985


One of the points with the C i++ versus i = i = 1 issue is the one of
pointers (although some alluded to it).

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:

	while (condition) /* or some other loop construct */
	  . . . 

	  argv++;

This will get us to the next pointer, whereas,

	  argv = argv + 1;

will NOT (unless by the happy happinstance that a pointer is exactly
the same size as a character!)

The only equivalent "clear" statement would be:

	argv = argv + sizeof(char *); !

I am not fond of the i++ idiom myself, however, the original author
severely oversimplified his case, I am afraid. 

After reading many dozens of messages going back and forth over this issue,
my own conlusion is that one can program simply using the absolute minumum
of idioms, one can cleverly use idioms that result in completely incomprehensible
code, or one can design simply, properly use the tools available, and develop
code that is conceptually simple, and uses the best of the tools in a way
which is understandable, repairable and extendable.


	



More information about the Comp.lang.c mailing list