Why the GNU compiler gives the warning while using gets() ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rajesh V
    New Member
    • Dec 2007
    • 16

    Why the GNU compiler gives the warning while using gets() ?

    When I use gets() function, the gcc compiler gives the warning - gets function is dangerous and should not be used. What is the problem in using it and how to avoid it ?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    gets() will overrun your buffer since it fetches characters until a \n or you run out of file. Not good. You need to use a function that fetches a known numberb of characters so you can control your input.

    Comment

    Working...