1

I have the two following C++ main function headers:

int main(int argc, char **argv)

int main(int argc, char** argv)

I know that the asterisk * signifies a pointer, but I do not understand the difference between these two. The one I usually see is char **argv, which, If I'm not mistaken, declares argv to be a pointer to a pointer to a char. If so, then what is char** argv?

The Pointer
  • 2,226
  • 7
  • 22
  • 50
  • There is no difference, It is just a readability difference. The first one states to be better. – starboy_jb Mar 10 '21 at 14:11
  • When C devs are around we act like `char **argv` is totally valid and oh, PLEASE, do tell us for the 10th time how things were when you developed on a 8088 IBM PC... But deep down C++ devs know `*` is an information about the type, and therefore it belongs to the left side of the "TYPE NAME;" declaration format. – m88 Mar 10 '21 at 15:05

1 Answers1

5

If so, then what is char** argv?

If (also) declares argv to be a pointer to a pointer to a char.

What is the difference between char **argv and char** argv?

The difference between them is the placement of space. There is no other difference. These are also the same:

char**argv

char                         *  *   argv

char
*
*
argv
eerorika
  • 232,697
  • 12
  • 197
  • 326
  • Check Stroustrup's FAQ entry on this topic: https://www.stroustrup.com/bs_faq2.html#whitespace – m88 Mar 10 '21 at 14:15