簡體   English   中英

為什么GCC抱怨gets()

[英]Why gcc is complaing about gets()

這是我的代碼(簡體):

#include <stdio.h>
#include <string.h>

#define SIZE 240

int main(void)
{
    char word[SIZE];
    gets(word);

    return 0;
}

為什么海灣合作委員會給我

№3.c: In function 'main': №3.c:13:2: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration]

這個警告?

GCC版本為5.2.1

PS程序正在運行。

PPS我將永遠不會使用gets(),我永遠不會使用gets(),我永遠不會使用gets(),我永遠不會使用gets()

功能gets不被C標准,因為它是一個不安全的功能支持了。 因此似乎函數聲明已從頭文件<stdio.h>排除,現在編譯器不知道gets的聲明是什么。

來自C標准(前言)

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。 與上一版相比的主要變化包括:

...

— removed the gets function (<stdio.h>)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM