Linux C语言编程错误解决之 “warning: the `gets' function is dangerous and should not be used.

2014-11-24 03:27:10 · 作者: · 浏览: 3

Linux C语言编程错误解决之 “warning: the `gets' function is dangerous and should not be used.”


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


fgets()函数的基本用法为:fgets(char * s,int size,FILE * stream);


/* 代码实现 */


#include
int main ( ) {


char crack8[20];


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


fgets(crack8, 20, stdin);//stdin 意思是键盘输入


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


return 0;
}