LearnFrenzy
Sign in Take a free test

C Input / Output · Input/Output MCQ · Question 3

Why was gets() removed from C? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

Why was gets() removed from the C standard in C11?

  • A It was too slow
  • B It cannot limit the input to the buffer size, so long lines overflow it Correct
  • C It did not handle newlines
  • D puts() replaced it
Correct Answer: Option B

gets takes only a pointer, so it has no idea how big the buffer is. fgets(buf, sizeof buf, stdin) is the safe replacement.

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