LearnFrenzy
Sign in Take a free test

Strings · String Basics MCQ · Question 3

Why was gets() removed from C11? 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 input to the buffer size, so it always risks a buffer overflow Correct
  • C It could not read spaces
  • D It was replaced by scanf()
Correct Answer: Option B

gets(buf) is never told how big buf is, so a long line overflows it – a classic security hole. Use fgets(buf, sizeof buf, stdin).

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