gpt4 book ai didi

c - 为什么 gcc 提示 gets()

转载 作者:行者123 更新时间:2023-12-02 08:22:46 25 4
gpt4 key购买 nike

这是我的代码(简化版):

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

#define SIZE 240

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

return 0;
}

为什么 GCC 给我

№3.c:在函数“main”中:
№3.c:13:2:警告:函数‘gets’的隐式声明[-Wimplicit-function-declaration]

这个警告?

GCC 版本是 5.2.1

P.S.该程序正在运行。

附言我永远不会用gets(),我永远不会用gets(),我永远不会用gets(),我永远不会用gets()

最佳答案

函数gets C 标准不再支持它,因为它是一个不安全的函数。所以函数声明似乎被排除在标题<stdio.h>之外现在编译器不知道 gets 的声明是什么.

来自 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. Major changes from the previous edition include:

...

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

关于c - 为什么 gcc 提示 gets(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35358767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com