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 ...
随机推荐
- Redis-shake工具 [ 自建redis集群->云redis主从 ]
redis-shake工具是阿里用go写的开源工具 开始前准备 1. 确保ECS实例与Redis实例属于同一专有网络(即实例基本信息中的专有网络ID一致) 2. 获取ECS实例的内网IP地址,即执行操 ...
- Maxim遍历测试工具(monkey升级版)
Maxim 对应GitHub地址:https://github.com/zhangzhao4444/Maxim,其是对Android monkey的改进工具.是基于遍历规则和高性能要求. 条件准备: ...
- Oracle ASM磁盘组的常用操作
1.查看现有磁盘组信息 select group_number gno,name,state,type,total_mb,free_mb,required_mirror_free_mb rmfmb,u ...
- CentOS系统 / 目录下每个子目录的作用
Text. 1./bin 该目录存放root和交互式登录用户使用的二进制可执行文件,如cat,cp,date,rm等. 2./boot 该目录主要存放系统启动所需要的相关文件,如何内核文件vmlinu ...
- express的安装,使用,请求,自动更新,静态资源托管(一)
1.打开编辑器vscode 2.安装express npm install express@4.17.1 3.创建文件index.js 4.导入express const express = ...
- linux 历史命令修改
一 添加历史命令时间和用户 echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >>/etc/profilesource /e ...
- Excel Vlookup用法和常见报错#REF! #Value!
VLOOKUP(E2,$A$2:$C$5,2,FALSE) E2 为选中查找的条件 $A$2:$C$5 1为需要查找的区域,这个区域一般是固定的,所以要加上$符号 2这个区域可以在前面加上SHEET2 ...
- 通过cmd对数据库SQL进行创建表空间并创建用户
通过cmd对数据库SQL进行创建表空间并创建用户 1.创建表空间:create tablespace stx(名字) datafile ' 目录路径\stx(名字).dbf ' size 64m; 2 ...
- bzoj 2337
有人说这题像游走... 关于游走的思想,他死了... 明明直接从期望dp的角度考虑更简单合理嘛 首先由于是异或运算不妨逐位考虑 对于每一位,设状态$f[i]$表示从第$i$个点到第$n$个点,这一位上 ...
- python批量导出、安装依赖库文件
导出: 在原环境中 pip freeze > fname.txt 安装: 在新环境中 pip install -r fname.txt 其中fname.txt 可以随意命名,其存储安装库文件列 ...