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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With