(1)
That's just how you'd call it in unix/linux world, which I guess the example I linked was based off of.
Don't worry too much about that, it's equivalent to just typing "my_program my args" or "my_program.exe my args" in Windows.
https://unix.stackexchange.com/questions/4430/why-do-we-use-to-execute-a-file
Edit: Ha, eec beat me.
(2)
Does it make a difference if I write int main(int argc, char** argv) or int main(int argc, char* argv) |
The first one is valid, the second is not.
In C++, a function having a parameter of
T* var
is the same thing as saying
T var[]
, because an array degrades into a pointer when passed to a function.
Therefore,
char* argv[]
and
char** argv
are the same thing when talking about function parameters, and are both valid for command-line arguments in
main's signature.
char* argv[] is saying it's an array of c-strings. char** argv is equivalent in this case, it's saying the same thing, but you can think of it as saying a pointer to a c-string.
Edit: As jonnin says below, don't worry too much about the syntax. Just know that that is the syntax used for command-line arguments.
What matters more is actually accessing the command-line arguments, which is just saying that each
argv[i] is a null-terminated c-string.