LearnFrenzy
Sign in Take a free test

Strings · String Basics MCQ · Question 8

Which is true about strtok() in C? Answer, explanation & discussion

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

Which statement about strtok() is true?

  • A It leaves the input string unchanged
  • B It writes '\0' into the string and keeps hidden state between calls Correct
  • C It returns empty tokens for ",,"
  • D It works on string literals
Correct Answer: Option B

strtok() replaces each delimiter it stops at with '\0' and remembers where it stopped. So the input must be writable, empty fields are skipped, and it is not safe to use for two strings at once.

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.

Popular