🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Command-Line Arguments in C: all 10 questions

Quiz: Command-Line Arguments in C · Question 6 of 10

A program uses argv[1] without checking argc and is run with no arguments. What happens?

A program uses argv[1] without checking argc and is run with no arguments. What happens?

  1. A.argv[1] is an empty string, so it works
  2. B.The compiler reports an error
  3. C.argv[1] is NULL, so using it as a string is undefined behaviour and usually crashes
  4. D.The program asks for input
Answer & explanation

Correct answer: argv[1] is NULL, so using it as a string is undefined behaviour and usually crashes

With no arguments, argc is 1 and argv[1] is the NULL that ends the array.

Can you get the rest right without peeking?

Take the timed Quiz: Command-Line Arguments in C quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →