Home / Questions / Out of fgets() and gets() which function is safe to use and why?
Explanatory Question

Out of fgets() and gets() which function is safe to use and why?

👁 1,853 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

fgets() is safer than gets(), because we can specify a maximum input length. Neither one is completely safe, because the compiler can't prove that programmer won't overflow the buffer he pass to fgets ().