Pointer Trouble Right Here in Unix City
Doug Gwyn <gwyn>
gwyn at brl-tgr.ARPA
Wed May 29 06:49:08 AEST 1985
> *(*argv + 2) ? *argv += 2 : argv++;
cond ? expr1 : expr2
If expr1 and expr2 are both pointers, they must have the same type.
(Section C.3.15 of ANSI X3J11/85-008)
You could write
*(*argv + 2) ? (*argv += 2) : *(argv++);
but this is hardly the most readable code in any case.
P.S. Consider using the public-domain getopt() that I posted
a while back. (You can easily disable the checks that preclude
-xargument style options in favor of -x argument. I think those
restrictions in the spec are pretty silly anyway.)
More information about the Comp.lang.c
mailing list