warning: the `gets' function is dangerous and should not be used.
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.的更多相关文章
- 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. 百度之 ...
- 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下的代码如下: ...
- warning: Unexpected unnamed function (func-names)
warning: Unexpected unnamed function (func-names) 看到这个提示基本是就是说你的函数不能是匿名函数,最好可以起一个名字,然后你增加一个函数名称就好了 R ...
- c语言中遇到“警告: the `gets' function is dangerous and should not be used.”的解决办法
写于2016年12月1日. 在用c的库函数gets(str)时,编译出现该提示.原因在于linux下gcc不支持gets命令,要换成fgets(arr,size,stdin).
- GCC,GDB,Makefile和IO复用函数
2015.1.22 c高级的环境搭建:GCC编译器:全称 GNU CC,是GNU工具(tool chain)的一种,源码编译成机器码,gcc的编译依赖于很多小工具4.3.3和3.4.3版本的比较稳定 ...
- Linux C 程序 字符串函数(12)
字符串函数C语言的字符串处理函数1.puts函数 //把一个以'\0'结尾的字符串输出到屏幕 char a[] = "Welcome to"; char *p = "Li ...
- -lrt
在编写pthread有关的程序时,编译时老是报"undefined reference to `pthread_create'"的错误,原因是没有链接pthread相关的库,gcc ...
- C app
1,C 输入输出字符串
- c语言基础学习06
=============================================================================涉及到的知识点有:1.C语言库函数.字符输入函 ...
- GlusterFS学习
环境准备 3台机器,每个机器双网卡,每个机器还需要额外添加1个10GB的磁盘用于测试 机器系统版本是centos6.6 [root@gluster-1-1 ~]# uname -rm 2.6.32-5 ...
随机推荐
- Access denied You do not have access to chat.openai.com. The site owner may have set restrictions that prevent you from accessing the site.解决办法
报错 Access denied You do not have access to chat.openai.com. The site owner may have set restrictions ...
- vue 3 打印 print-js
1.安装 npm install print-js --save 2.引用 import print from 'print-js' 3.编写打印函数 const enterDialog = asyn ...
- Chrome 中设置默认搜索引擎为 google.com
https://google.com/search?q=%s&ref=opensearch&safe=off 那么就可以使搜索结果默认在新标签页打开,同时关闭了搜索结果的安全过滤. ...
- FFmpeg 命令行
FFmpeg命令行帮助 #>ffmpeg -h #>ffmpeg -h long #>ffmpeg -h full 将视频按照指定的宽高输出 #>ffmpeg -i input ...
- Study python_01
Python历史事件 1989 年 --- 荷兰人吉多·范罗苏姆决心开发一个新的脚本解释程序: 1991 年 --- 第一个用C语言实现的Python编译器诞生,Python 的代码对外公布,版本为 ...
- Windows开机自动运行.bat文件
方法/步骤:一:打开我的电脑, 在地址栏输入:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" 二,把自 ...
- python基础篇 15-常用模块:random string sorted lambda函数
一.random import os,random,sys,time,string print(random.randint(1,10)) # 产生随机的整数 print(random.uniform ...
- Vue获取DOM的几种方法
虽然Vue实现了MVVM模型,将数据和表现进行了分离,我们只需要更新数据就能使DOM同步更新,但是某些情况下,还是需要获取DOM元素进行操作(比如引入的某个库要求传入一个根dom元素作为根节点,或者写 ...
- webpack打包分析webpack-bundle-analyzer 打包文件分析工具
最近需要减少项目打包后的文件(bundle)的大小,那么首先需要了解bundle的构成. 目前我已知的方法有两种: 利用webpack-bundle-analyzer插件 利用webpack官方提供的 ...
- https://计算机等级分类总结
4个等级: 一级:定位为满足人们在一般性工作中对计算机的应用,重点是操作能力的考核: 二级:定位为计算机程序员,可谓"计算机蓝领". 三级:定位为"开发工程师" ...