Mail Archives: djgpp/1997/06/09/09:48:39
>> I've seen char **argv and char *argv[] and am curious which is correct
Or
>> are either correct?
> They are both the same thing. The array syntax is interchangable with
> pointer
> arithmetic. Or at least should be if the compiler in question follows
the
> language at all.
Not exact. The are both the same thing only when used as parameters
to functions (like in main).
char* argv1[] (not as a parameter) is an array of pointer
variables.
char** argv2 (always) is a pointer (variable holding the address of) a
pointer-to-char.
for example :
extern char* argv1[]; /* declares array of pointers. */
extern char **argv2;
argv1++; // ERROR this is an array !!
argv2++; // OK.
so there is difference.
Eyal.
- Raw text -