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

Discussion

What is the second argument in command line arguments?

  • A.The number of command-line arguments the program was invoked with;
  • B.A pointer to an array of character strings that contain the arguments, one per string
  • C.Nothing
  • D.None of the mentioned

Answer: B

Correct answer: A pointer to an array of character strings that contain the arguments, one per string

The second parameter is argv. Declared char *argv[] it is an array of pointers, and as a parameter it decays to a pointer to its first element, which is how char **argv comes to be an equivalent declaration.

Each element addresses one null-terminated argument, with argv[0] naming the program and argv[argc] guaranteed null. The first parameter, argc, carries the count of those strings.

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

Post your comment

Please log in or register to post a comment.