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[]变量,10为要输入的字符串长度,stdin为从标准终端输入。

如:

以前:char  str[100];

  gets(str);

修改之后:

char str[100];
fgets(str,100,stdin);

注意:
gets从终端读入是的字符串是用\0结束的,而fgets是以\n结束的(一般输入都用ENTER结束)

warning: the `gets' function is dangerous and should not be used.的更多相关文章

  1. warning: the `gets' function is dangerous and should not be used.(转)

    今天在LINUX下编译C程序时,出现了:warning: the `gets' function is dangerous and should not be used. 这个warning. 百度之 ...

  2. linux系统下,警告:warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration] 和 warning: the `gets' function is dangerous and should not be used. 的由来和解决方法。

    字符数组 的英文名字是 char [] gets()函数的基本用法为:char *gets(char *s); 该函数的参数是一个字符数组,该函数的返回值也是一个字符数组. linux下的代码如下: ...

  3. warning: Unexpected unnamed function (func-names)

    warning: Unexpected unnamed function (func-names) 看到这个提示基本是就是说你的函数不能是匿名函数,最好可以起一个名字,然后你增加一个函数名称就好了 R ...

  4. c语言中遇到“警告: the `gets' function is dangerous and should not be used.”的解决办法

    写于2016年12月1日. 在用c的库函数gets(str)时,编译出现该提示.原因在于linux下gcc不支持gets命令,要换成fgets(arr,size,stdin).

  5. GCC,GDB,Makefile和IO复用函数

    2015.1.22 c高级的环境搭建:GCC编译器:全称 GNU CC,是GNU工具(tool chain)的一种,源码编译成机器码,gcc的编译依赖于很多小工具4.3.3和3.4.3版本的比较稳定 ...

  6. Linux C 程序 字符串函数(12)

    字符串函数C语言的字符串处理函数1.puts函数 //把一个以'\0'结尾的字符串输出到屏幕 char a[] = "Welcome to"; char *p = "Li ...

  7. -lrt

    在编写pthread有关的程序时,编译时老是报"undefined reference to `pthread_create'"的错误,原因是没有链接pthread相关的库,gcc ...

  8. C app

    1,C 输入输出字符串

  9. c语言基础学习06

    =============================================================================涉及到的知识点有:1.C语言库函数.字符输入函 ...

  10. GlusterFS学习

    环境准备 3台机器,每个机器双网卡,每个机器还需要额外添加1个10GB的磁盘用于测试 机器系统版本是centos6.6 [root@gluster-1-1 ~]# uname -rm 2.6.32-5 ...

随机推荐

  1. oracle中将同一组的数据拼接(转)

    需要用wm_concat函数来实现. 如目前在emp表中查询数据如下: 要按照deptno相同的将ename以字符串形式合并,可用如下语句: 1 select deptno,wm_concat(ena ...

  2. Pycharm实现sqlite数据库可视化

  3. antVue--a-cascader级联组件使用触发loadData方法注意事项

    <template> <a-cascader :options="options" :load-data="loadData" placeho ...

  4. python如何实现对word内段落文本及表格的读取

    在以下方法中用到的三方库是:python-docx from docx import Document 获取指定段落的文本 def get_paragraph_text(path, n): " ...

  5. 常见DOS命令及应用

    常见DOS命令使用 CMD打开方式 开始 + 系统 + 命令提示符 WIN键 + R 输入cmd + Enter WIN键 + R 输入cmd + Ctrl + Shift + Enter (管理员模 ...

  6. 逆向学习物联网-网关ESP8266-04系统联合调试

    1.测试平台原理 2.搭建硬件测试平台 3.软件测试平台 1)串口终端 2)串口监视 3)OneNET后台服务 https://open.iot.10086.cn/passport/login/ 户名 ...

  7. [iOS] 对 UItableView 等界面(ClipsToBounds) 同时使用 圆角和阴影

    展示内容的界面会被 ClipsToBounds = YES(按边缘剪切),但同时需要圆角和阴影效果. 一个界面,ClipsToBounds = YES 之后,阴影会被剪切,不再展示. 感觉只能使用多个 ...

  8. FPGAUSB控制器编程

    FPGA产生PLL LED子module,显示FPGA在运行 USB控制子module,USB时钟输入,状态输入,总线输出,USBFIFO地址总线,数据双向总线. USB状态机,Flaga有效时,转为 ...

  9. 微软开源 Python 自动化神器 Playwright

    背景 逛博客时候突然看到 Playwright web自动化,感觉很有意思,就翻看了很多博客,简单记录一下. 简介 Playwright是一个强大的Python库,仅用一个API即可自动执行Chrom ...

  10. html页面下载为docx文档

    1.安装要用到的两个插件:html-docx-js-typescript.file-saver. 2.导入两个方法: import { asBlob } from 'html-docx-js-type ...