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

Discussion

Which of the following gives the name of the program if the second parameter to the main fucntion is char **argv?

  • A.argv[3]
  • B.argv[1]
  • C.argv[0]
  • D.argv[2]

Answer: C

Correct answer: argv[0]

argv[0] holds the name by which the program was invoked, whether argv is declared as an array of pointers or as char ** - the two are equivalent as parameters.

The arguments proper begin at argv[1], which is why a program testing for arguments writes if (argc > 1). The exact contents of argv[0] are a platform convention: Unix-like systems supply the string as typed, while some others give a full path.

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

Post your comment

Please log in or register to post a comment.