I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » Tutorials » C & C++ » Basic »

*argv[] versus **argv

CodeCogs\′s Photo
9 Nov 07, 6:55PM
*argv[] versus **argv
The declaration of the argv argument in the main function:
int main(int argc, char* argv[])
{ ... }
is often a novice programmer's first encounter with pointers to arrays of pointers and can prove intimidating. However, it is really quite simple to understand. Since argv is used to refer to an array of strings, its declaration will look like this:
char *argv[]
Remember too that when it is passed to a function, the name of an array is converted to the address of its first element. This means that we can also declare argv as char **argv; the two declarations are equivalent in this context.

See http://publications.gbdirect.co.uk/c_book/chapter10/arguments_to_main.html for more
Currently you need to be logged in to leave a message.