int main(int argc, char **argv)
{}
Is it possible that
argc
equals 0?Must
argv[0]
be the executable file's name?Is there any standard for these issues?
int main(int argc, char **argv)
{}
Is it possible that argc
equals 0?
Must argv[0]
be the executable file's name?
Is there any standard for these issues?
Yes.
Normally yes, it could also be empty, or some other identifying string, or even NULL
(see my addendum). It's also possible to change argv[0]
to something else from inside the program.
The C (and C++) specifications.
You also missed one: The last element in argv
is always NULL
, meaning argv[argc]
will always be NULL
.
In the C11 specification it's in §5.1.2.2.1 Program startup.
In the C++11 specification its §3.6.1 Main function.