Pointer Trouble Right Here in Unix City
Ron Natalie <ron>
ron at brl-tgr.ARPA
Wed May 29 11:54:02 AEST 1985
> case 'b':
> *(*argv + 2) ? *argv += 2 : argv++;
>
It's upset because the "true" expression and the "false" expression
are of different. Turn to page 191 in K&R and read along with me:
"If both are pointers of the same type, the result has the common
type, otherwise, one must be a pointer and the other the constant 0"
A disgusting fix is to make the false expression "*argv++"
I don't know why people have an aversion to readable code.
First what is wrong with an IF/ELSE combination here? It's what you
are doing. You are not selecting one of two expressions, but choosing
to do one evaluation or the other. It's up to you, but it seems muddle-
some to me. My bigger complaint is
*(*argv + 2)
Give me a brake they put the brackets in C so you wouldn't have to do every-
thing with *.
How about
argv[0][2]
???
More information about the Comp.lang.c
mailing list