In any C program, the command line argument argv[0] points to the name used to invoke the program. Is there any circumstance in which it will point to an empty string ""?
An example code snippet for such a case would be a good reference.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s implementation defined. §5.1.2.2.1 abridged:
So if
argcis greater than zero, it’s quite the intention thatargv[0]never be an empty string, but it could happen. (Note that withargcequal ton,argv[0]throughargv[n - 1]are never null and always point to a string. The string itself may be empty, though. Ifnis zero,argv[0]is null.)In practice, of course, you just need to make sure the platforms your targetting behave as needed.