warning: the `gets' function is dangerous and should not be used.

使用的是 Fedora 10 gcc编译下面程序 显示

warning: the `gets' function is dangerous and should not be used.

问题出在程序中使用了 gets Linux 下gcc编译器不支持这个函数,解决办法是使用 fgets

fgets()函数的基本用法为:

fgets(char * s,int size,FILE * stream);

/*   代码实现     */

#include <stdio.h>
int main ( ) {

   char name[20];

   printf("\n 输入任意字符 : ");

   fgets(name, 20, stdin);//stdin 意思是键盘输入,并且会包括回车符号

   fputs(name, stdout); //stdout 输出

   return 0;
}
原文地址:https://www.cnblogs.com/joeblackzqq/p/2011277.html