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

Discussion

Which of the following statements are FALSE about the below code?

int main(int ac, char *av[])
{
}

 

  • A.ac contains count of arguments supplied at command-line
  • B.av[] contains addresses of arguments supplied at a command line
  • C.In place of ac and av, argc and argv should be used.
  • D.The variables ac and av are always local to main()

Answer: C

Correct answer: In place of ac and av, argc and argv should be used.

That is the false statement. The names are conventional, not required: the compiler cares only that the first parameter is an int and the second a char **, so ac and av work exactly as well.

The other three are true. ac holds the count of arguments including the program name, av[] holds their addresses, and both are ordinary parameters of main and therefore local to it - which is why passing them on to other functions, or copying them into globals, is necessary.

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

Post your comment

Please log in or register to post a comment.