Implicit declaration of ‘gets’

You are right that if you include proper headers, you shouldn’t get the implicit declaration warning.

However, the function gets() has been removed from C11 standard. That means there’s no longer a prototype for gets() in <stdio.h>. gets() used to be in <stdio.h>.

The reason for the removal of gets() is quite well known: It can’t protect against the buffer overrun. As such, you should never use gets() and use fgets() instead and take care of the trailing newline, if any.

Leave a Comment