🎙 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 5 of 10

Why is strtol better than atoi for reading a number from argv?

Why is strtol better than atoi for reading a number from argv?

  1. A.strtol shows where conversion stopped, so input like "12abc" or "abc" can be rejected
  2. B.atoi cannot convert strings at all
  3. C.strtol is the only function that handles negative numbers
  4. D.atoi changes the argv array
Answer & explanation

Correct answer: strtol shows where conversion stopped, so input like "12abc" or "abc" can be rejected

atoi returns 0 or a partial number without any error signal.

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 →