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

Discussion

Which of the following is correct about the first parameter of the main function?

  • A.First argument is of int type
  • B.Stores the count of command line arguments
  • C.First argument is non-negative
  • D.All of the mentioned

Answer: D

Correct answer: All of the mentioned

All three statements hold. argc is declared int; it stores the count of command-line arguments; and it is non-negative, since a count cannot be less than zero.

In practice it is at least 1, because the program name occupies argv[0] and is counted. The standard does allow 0, in which case argv[0] is a null pointer, but that arises only from an exec call supplying no name at all - never from an ordinary shell.

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

Post your comment

Please log in or register to post a comment.