Help understanding char* argv[]

I have read that argv is an abbreviation for ``argument vector''. It is the traditional name for a pointer to an array of string pointers passed to a C program's main function;

So then why is argv written as "char* argv[]"? That tells me that argv is an array of pointers to chars. Shouldn't it be written as "string* (*argv)[]"? Can anyone help clear this up?
Basically you can pass parameters to a program, say u open a file with paint, it sends location.

Or if you run a terminal program java -jar filename.

Remember a string literal in an array is a 2 dimensional array.
Last edited on
I understand how to use argv, just not why it works.
That tells me that argv is an array of pointers to chars.

Yes, that's what it is. Pointers to chars, char*, are C-style strings. They're arrays of characters with a terminating '\0' character (ASCII 0) that says when the "string" ends.
Last edited on
Well that would take care of the strings, but the definition for argv says that it is a pointer to an array of pointers to chars, not and array of pointers to chars. Shouldn't it be written as char* (*argv)[]
but the definition for argv says that it is a pointer to an array of pointers to chars

No it doesn't. That definition is wrong. argv is an array of C-style strings. argv can also be declared as char** argv.
Topic archived. No new replies allowed.