gpt4 book ai didi

c++ - gets() 函数在 Visual Studio 2015 社区中不可用

转载 作者:可可西里 更新时间:2023-11-01 18:04:22 31 4
gpt4 key购买 nike

我在新安装的 Visual Studio Community 2015 IDE 中遇到编译器错误 (c3861):

我只想使用 stdio.h 库中的 gets() 函数,并且我在我的程序中包含了 stdio.h 文件,但编译器显示了一个编译器错误如下所示:

error C3861: 'gets': identifier not found 

我应该怎么做才能使用gets() 函数正确编译我的程序。

最佳答案

从 C11 开始,getsgets_s 取代。 gets() 函数不执行边界检查,因此该函数极易受到缓冲区溢出的影响。推荐的替代品是 gets_s()fgets()

gets_s(buf);
fgets(buf, sizeof(buf), stdin);

关于c++ - gets() 函数在 Visual Studio 2015 社区中不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32283650/

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