warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]

5.c: In function ‘getinfo’:
5.c:20:2: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(temp.fname);

警告:不建议使用gets函数。

gets 已被弃用,因为它很危险,可能会导致缓冲区溢出。

解决方案使用 fgets 代替: fgets(temp,sizeof(temp),stdin);

虽然用 gets() 时有空格也可以直接输入,但是 gets() 有一个非常大的缺陷,即它不检查预留存储区是否能够容纳实际输入的数据,换句话说,如果输入的字符数目大于数组的长度,gets 无法检测到这个问题,就会发生内存越界,所以编程时建议使用 fgets()。

fgets() 的原型为:

# include <stdio.h>
char *fgets(char *s, int size, FILE *stream);

# include <stdio.h>
int main(void)
    char str[20];  /*定义一个最大长度为19, 末尾是'\0'的字符数组来存储字符串*/
    printf("请输入一个字符串:");
    fgets(str, 7, stdin);  /*从输入流stdin即输入缓冲区中读取7个字符到字符数组str中*/
    printf("%s\n", str);
    return 0;
#include <stdio.h>
int main( )
   char str[100];
   printf( "Enter a value :");
//    gets( str );
   fgets(str, 100, stdin); 
   printf( "\nYou entered: ");
   puts( str );
   return 0;
                    warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
                    warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]5.c: In function ‘getinfo’:5.c:20:2: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]gets(temp.fname);警告..
				
1、问题描述 编译FFmpeg程序时,经常报一些关于“deprecated”的警告信息,具体内容如下: decode.cpp:28:2: warning: ‘void av_register_all()’ is deprecated [-Wdeprecated-declarations] av_register_all(); decode.cpp:34:2: warning: ‘void av...
Gopher This is the deprecated Slack bot for the Gophers Slack. The new version can be found here. You can get an invite from Running To run this you need to set the the following environment variables: GOPHERS_SLACK_BOT_TOKEN - the Slack bot token GOPHERS_SLACK_BOT_NAME - the Slack bot name GOPHERS_SLACK_BOT_DEV_MODE - boolean, set the bot in development mode OLD Instructions Note: Not sure any o
NEWGAL>PCXVFB: Wait too long for CLIENT. NEWGAL: Does not find matched engine: pc_xvfb. Or failed to initialize the engine. KERNEL>InitGUI (step 7): Can not get graphics engine information! 2.执行idea.bat OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. Error occurred during initialization of VM Initial heap size set to a larger value than the maximum heap size
出现上面这个问题时我查了一下,有说用管理员身份打开keil软件就能进行正常的编译,我试了一下发现可以,然后我就思考这个问题:能不能不用每次用管理员身份打开就能顺利编译呢,分析问题如下 1.用管理员身份运行能成功编译说明keil的文件stdint.h应该没问题,文件应该是存在且正常的,并不需要像网上有些说的那样要重装keil或者是要在工程中再添加文件 2.既然文件没问题,...
5.c: In function ‘getinfo’: 5.c:20:2: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations] gets(temp.fname); 警告:不建议使用gets函数。 gets 已被弃用,因为它很危险,可能会导致缓冲区溢出。 解决方案使用 fgets 代替: fgets(temp,sizeof(temp),stdin);
linux C语言编程错误解决之 “warning: the `gets' function is dangerous andshould not be used.” 问题出在程序中使用了 gets Linux 下gcc编译器不支持这个函数,解决办法是使用fgets fgets()函数的基本用法为: fgets(char * s,int size,FILE * stream); 能够make成功100%,但是在链接过程中终端打印信息提示 warning: XXX is deprecated [-Wdeprecated-declarations] \\ XXX代表某函数 这是一句警告,简单来说就是在你代码中使用的XXX函数已经被弃用了。 具体发生原因暂时不清楚,可能,我说的是可能,新链接的某个库对你在头文件定义的XXX函数,函数名字进行了替换 warning不影响
警告: ‘gets’ is deprecated (declared at /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/stdio.h:638) [-Wdeprecated-declarations] gets(str);
wget -qO - https://example.com/mykey.gpg | sudo apt-key add - Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). gpg: 找不到有效的 OpenPGP 数据。
1. URL 不正确或无法访问。请确认 URL 是否正确,并尝试从浏览器中打开该 URL,以确认是否可以访问。 2. GPG 密钥文件不存在或不正确。请确认密钥文件的路径和名称是否正确,并尝试重新下载密钥文件。 3. GPG 密钥文件已被损坏。请尝试重新下载密钥文件,并使用 gpg 命令验证密钥文件的完整性。 4. GPG 密钥文件已过期。请确认密钥文件是否已过期,并尝试重新下载密钥文件。 5. 系统中缺少必要的 GPG 组件。请确认已安装 gnupg 和 dirmngr 组件,并尝试重新运行命令。 针对第一个警告,可以尝试使用如下命令代替: curl -sSL https://example.com/mykey.gpg | sudo gpg --dearmor --output /usr/share/keyrings/mykey.gpg 然后使用如下命令导入密钥: sudo apt-key adv --keyserver keyserver.ubuntu.com --no-default-keyring --keyring /usr/share/keyrings/mykey.gpg --recv-keys [KEY-ID] 注意将 `[KEY-ID]` 替换为你的密钥 ID。
Ubuntu:虚拟机安装Ubuntu,首次重启后,报please remove the installation medium then press enter错误 m0_73731628: 呜呜呜感谢感谢