Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is argv[0] in command line arguments?

  • A.The name by which the program was invoked
  • B.The name of the files which are passed to the program
  • C.Count of the arguments in argv[] vector
  • D.None of the mentioned

Answer: A

Correct answer: The name by which the program was invoked

argv[0] holds the program name as invoked, which is why argc is 1 rather than 0 when no arguments follow.

The exact contents are a platform convention: Unix-like systems generally supply the string the user typed, while Turbo C under DOS supplies the full uppercase path. Nor is it necessarily a real filename - an exec call may pass any string - which is what allows one binary to behave differently according to the name it is called by.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.