[英]Why gcc is complaing about gets()
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 GCC版本为5.2.1
PSThe program is working. PS程序正在运行。
PPS I will never use gets(), I will never use gets(), I will never use gets(), I will never use gets() PPS我将永远不会使用gets(),我永远不会使用gets(),我永远不会使用gets(),我永远不会使用gets()
Function gets
is not supported by the C Standard any more because it is an unsafe function. 功能
gets
不被C标准,因为它是一个不安全的功能支持了。 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
. 因此似乎函数声明已从头文件
<stdio.h>
排除,现在编译器不知道gets
的声明是什么。
From the C Standard (Foreword) 来自C标准(前言)
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.
6第三版取消并代替了第二版ISO / IEC 9899:1999,该版本已通过ISO / IEC 9899:1999 / Cor 1:2001,ISO / IEC 9899:1999 / Cor 2:2004和ISO / IEC 9899的更正:1999 / Cor 3:2007。 Major changes from the previous edition include:
与上一版相比的主要变化包括:
... ...
— removed the gets function (<stdio.h>)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.