`
zhcheng
  • 浏览: 163317 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

    博客分类:
  • C
 
阅读更多

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[80];
        //fgets()函数的基本用法为:
        //fgets(char * s,int size,FILE * stream);
        fgets(s,80,stdin);//stdin表示键盘输入
        fputs(s,stdout);//stdout表示输出
        return 0;
}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics