Multiple choice technology programming languages

What does the argument count variable store which is paased to main()?

  1. the number of arguments

  2. the number of arguments plus one

  3. the number of arguments minus one

  4. The total size of the argument array

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The argument count (argc) includes the program name as argv[0], so it's always one more than the number of command-line arguments passed. If you run ./prog arg1 arg2, argc is 3 (program name + 2 arguments). This is why argc equals number of arguments plus one, not just the argument count.