0

Reading code, I see individuals pass command-line arguments to main() in two different ways. Often, and the way I choose to do it, is a pointer to an array containing the arguments (char *argv[]). I will also see code which uses a pointer to a pointer to the argument(s) instead (char **argv).

These seem very similar and I'm not sure whether there is any pragmatic reason for choosing to do this one way or another. Could anybody let me know why?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Rowan
  • 351
  • 2
  • 13
  • 1
    The two are equivalent - pick whichever one you like best. – Paul R Mar 09 '20 at 18:07
  • Your description is not quite correct - it is an array of pointers, not a pointer to an array. One difference is that within the function main, you can assign char** `argv` to a different local intirect string instance, but you can't assign `argv[]` - it is considered const at that level. – Gem Taylor Mar 09 '20 at 18:20

0 Answers0