← 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?
- A.strtol shows where conversion stopped, so input like "12abc" or "abc" can be rejected
- B.atoi cannot convert strings at all
- C.strtol is the only function that handles negative numbers
- 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 →