Mail Archives: djgpp/1997/06/11/20:50:23
Andrea Glorioso wrote:
> I guess they mean exactly the same, because declaring a variable int a[]
> is pretty equal to declaring int ** a.
Be careful about this; pointers and arrays are _not_ the same. They can
be manipulated in a few different ways, but they are _not_ identical.
> I've seen char * argv[] and
> char** argv being used many times without problems. I think they are
> also compiled in the same way, but maybe you should try to compile to
> assembly code to figure it out.
. . . except in the case of function arguments. A function with an
argument of a single-dimensioned array is treated in all ways identically
to a pointer. That is, a function with prototype
f(int ai[]);
is treated precisely the same as one with prototype
f(int *ai);
Since main is just another function, this applies to it as well. Either
char **argv (pointer to pointer to char) or char *argv[] (array of pointer
to char) are both treated the same, and so both are legal. (Note that
char (*argv)[], or pointer to array of char, would be illegal.)
--
Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
Alcyone Systems / web / http://www.alcyone.com/max/
San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
\
"Covenants without the sword / are but words."
/ Camden
- Raw text -