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

Discussion

What does the first parameter of the main function represent?

  • A.Number of command line arguments
  • B.List of command line arguments
  • C.Dictionary of command line arguments
  • D.Stack of command line arguments

Answer: A

Correct answer: Number of command line arguments

The first parameter is argc, an int giving how many arguments the program was invoked with - the program name included, so a bare invocation gives 1.

The list of the arguments themselves is the second parameter, argv. C has neither dictionaries nor stacks as language constructs, so those options describe nothing the runtime could supply. The count exists because the array itself carries no length, only a null pointer at its end.

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

Post your comment

Please log in or register to post a comment.