LearnFrenzy
Sign in Take a free test

C Library Functions · Library Functions MCQ · Question 10

What does strtok() do to its input string? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

Which statement about strtok() is true?

  • A It never changes the input
  • B It writes '\0' over delimiters in the input and keeps internal state between calls, so it cannot be used on string literals Correct
  • C It returns a newly allocated copy of each token
  • D It returns empty tokens between adjacent delimiters
Correct Answer: Option B

Pass a writable array on the first call and NULL on later calls. Adjacent delimiters are skipped, so "a,,b" gives two tokens.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links