-
Passing arguments
When you want to pass arguments to main one of the arguments is char *argv[]. To me this means pointer to array of characters. How is it possible then to pass more than one character long arguments. Obviously I know you can I just would like tounderstand
-
It's an array of pointers. Each point points to an area of storage big enough to hold the argument.
Regardless, in C++, you should use std::vector and std::string instead. And don't call main.
-
Its a pointer to an array of pointers each pointing to an array of characters. Keep in mind that there is generally* no difference between a pointer to a type and a pointer to an array of that type.
That particular syntax serves to emphasize that it is an array of char pointers. An array passed to a function degenerates to a pointer.
The other equivelent way to declare argv is "char **argv". This states that argv is a pointer to one or more char pointers, which each could point to one or more chars.
*is is possible to declare a pointer to an array, but it is never use because it is incompatible with dynamic arrays.