说明:红色部分很好地解释了“the 'gets' function is dangerous and should not be used”这个warning的原因。 参考链接:http://www.cplusplus.com/reference/clibrary/cstdio/gets/
LINUX下编译C程序时,出现了: warning: the `gets' function is dangerous and should not be used. 原因:Linux 下gcc编译器不支持gets()这个函数,解决办法是使用 fgets fgets()函数的基本用法为: fgets(char * s,int size,FILE * stream); //eg:可以用fgets(tempstr,10,stdin) //tempstr 为char[]变量,...
Why is the gets function so dangerous that it should not be used? (13 answers) Closed 9 years ago. When i use gets function,gcc gives me a warning: warning:the `gets' function is dangerous and should not be used. Why gets and puts function dangerous? c Share Improve this question ...
在使用C语言中的gets()函数时,可能会出现一些报错。以下是一些常见的解决方法: 错误:gets() is dangerous and should not be used. 解决方法:使用更安全的函数fgets()来代替gets()。 错误:warning: the gets function is dangerous and should not be used. 解决方法:同样使用fgets()函数来代替gets()。 错误...
linux系统下,警告:warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration] 和 warning: the `gets’ function is dangerous and should not be used. 的由来和解决方法。 字符数组 的英文名字是 char [] gets()函数的基本用法为: ...
linux C语言编程错误解决之 “warning: the `gets' function is dangerous and should not be used.” 问题出在程序中使用了getsLinux 下gcc编译器不支持这个函数,解决办法是使用fgets fgets()函数的基本用法为: fgets(char * s,int size,FILE * stream); ...
When I try to compile C code that uses the gets() function with GCC, I get this warning: (.text+0x34): warning: the `gets' function is dangerous and should not be used. I remember this has something to do with stack protection and security, but I'm not sure exactly why. How ...
main.c:(.text+0x30): warning: the `gets' function is dangerous and should not be used. 1. 2. 3. 4. 5. 6. 虽然能够运行,但作为一个强迫症患者怎么能允许代码有警告出现呢?我们可以从警告的提示可以看到,gets函数是危险的,不建议去使用。这不就是自相矛盾吗!既然危险,为何又要去写这个API呢!其...
gets()方法在linux下使用gcc编译时会出现下列问题: warning: the `gets' function is dangerous and should not be used. 解决办法是使用 fgets()。 #include <stdio.h> #include <string.h> int main(){ char s ...
linux系统下,警告:warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration] 和 warning: the `gets' function is dangerous and should 简介:字符数组 的英文名字是 char [] gets()函数的基本用法为:char *gets(char *s); 该函数的参数是一个字符数组,该函数的返回值也是一个...