candide wrote:
Nope. It is most correctly 'char **argv', pointer to pointer to char.
Declaring 'char *argv[]' is exactly equivalent. It says argv is an array
of pointers to char. Expressing argv as an array yields a pointer to its
first element.
I believe 'array of strings' is misleading. It is 'array of pointer to
char' in fact.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Hi,
>
K&R2 §5.10 tells that the second parameter to the main function,
usually called argv, has type pointer to character strings.
>
Some quotes from the book :
>
>
-------------------- 8< ----------------------------------------
"the second (argv, for argument vector) is a pointer to an array of
character strings"
>
"Since argv is a pointer to an array of pointers,"
>
"Since argv is a pointer to the beginning of the array of argument strings"
-------------------- >8 ----------------------------------------
>
>
In fact, argv is rather an array of strings, as explained in the
preceding § :
>
>
-------------------- 8< ----------------------------------------
"Compare the declaration and picture for an array of pointers:
char *name[] = { "Illegal month", "Jan", "Feb", "Mar" };"
-------------------- >8 ----------------------------------------
>
>
Right ?
>
Thanks
>
K&R2 §5.10 tells that the second parameter to the main function,
usually called argv, has type pointer to character strings.
>
Some quotes from the book :
>
>
-------------------- 8< ----------------------------------------
"the second (argv, for argument vector) is a pointer to an array of
character strings"
>
"Since argv is a pointer to an array of pointers,"
>
"Since argv is a pointer to the beginning of the array of argument strings"
-------------------- >8 ----------------------------------------
>
>
In fact, argv is rather an array of strings, as explained in the
preceding § :
>
>
-------------------- 8< ----------------------------------------
"Compare the declaration and picture for an array of pointers:
char *name[] = { "Illegal month", "Jan", "Feb", "Mar" };"
-------------------- >8 ----------------------------------------
>
>
Right ?
>
Thanks
Declaring 'char *argv[]' is exactly equivalent. It says argv is an array
of pointers to char. Expressing argv as an array yields a pointer to its
first element.
I believe 'array of strings' is misleading. It is 'array of pointer to
char' in fact.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Comment