This is my code(simplified):
#include <stdio.h>
#include <string.h>
#define SIZE 240
int main(void)
{
char word[SIZE];
gets(word);
return 0;
}
Why GCC is giving me
№3.c: In function 'main': №3.c:13:2: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration]
this warning?
GCC vesion is 5.2.1
PSThe program is working.
PPS I will never use gets(), I will never use gets(), I will never use gets(), I will never use gets()
Function gets
is not supported by the C Standard any more because it is an unsafe function. So it seems the function declaration was excluded from the header <stdio.h>
and now the compiler does not know what is the declaration of the gets
.
From the C Standard (Foreword)
6 This third edition cancels and replaces the second edition, ISO/IEC 9899:1999, as corrected by ISO/IEC 9899:1999/Cor 1:2001, ISO/IEC 9899:1999/Cor 2:2004, and ISO/IEC 9899:1999/Cor 3:2007. Major changes from the previous edition include:
...
— removed the gets function (<stdio.h>)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.