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!