C language arguments [] and *

The other day, did you find a code that writes this in the prototype of the main function? It became.

int main(int argc, char **argv) {
/* ... */
}

Certainly, in the textbook, wasn't the argument of the main function like this?

int main(int argc, char *argv[]) {
/* ... */
}

Both seem to compile.

Certainly, ʻint argv [] in the argument is similar because the address of the beginning of the array is passed like ʻint * argv.

Personally, I think it's easier to read if you write it according to the textbook, with the meaning that an array of char pointers will be passed.

Recommended Posts