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 ...
随机推荐
- I3D论文总结
最近看了李沐讲论文系列朱毅老师讲的I3D论文精读(视频,笔记),这里记录一下. 1.针对的问题 1.之前的视频数据集都太小,导致大多数流行的动作识别基准都很小,且即使不同模型效果有好有坏也难以区分. ...
- ORACLE备份脚本(3-RMAN0级全备)
创建目录 mkdir -p /bak/level0 mkdir -p /bak/arch chown -R oracle:oinstall /bak/ vi rmanlevel0.sh # ...
- DEV GridControl 主从表 (层次表)
DataTable dtData= DbHelperOra.Query(strSql2.ToString()).Tables[0]; //主表 dtusers.TableName = "病人 ...
- 使用react脚手架创建项目报错-You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1).
创建项目报错: You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1). We no ...
- linux挂载文件服务器
smbclient -L //192.168.1.1/ -U administrator //直接挂载 使用下面这条命令就行 sudo mount -t cifs -o username=文件服务器账 ...
- XSStrike-20220320
Usage: xsstrike.py [-h] [-u TARGET] [--data PARAMDATA] [-e ENCODE] [--fuzzer] [--update] [--timeout ...
- Taro 弹窗阻止小程序滑动穿透(亲测有效) tabbar数据缓存不更新 入口场景值不同
v3.0 推出后反馈最多的问题之一,就是在 touchmove 事件回调中调用 e.stopPropagation() 并不能阻止滑动穿透. 这是因为 Taro 3 的事件冒泡机制是单独在小程序逻辑层 ...
- Codeforces Round #728 (Div. 2) C. Great Graphs
Great Graphs 题意 给你一个数组\(d\),\(d[i]\)表示从节点\(1\)到其他各个节点的最短路的长度,然后你可以对这个图进行加边(可以是负边),但不允许存在一个权值和为负数的回路. ...
- 七牛云服务器debug
400{ResponseInfo:com.qiniu.http.Response@16fd3806,status:400, reqId:uzcAADGFlzHUE-kW, xlog:-, xvia:, ...
- python 安装步骤
1.这个安装方法不需要配置环境变量 2. 3. 4.进入cmd,输入python -v