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 ...
随机推荐
- 1.win10安装centos虚拟机并设置允许远程
一.下载并安装 打开如下连接,下载VMware和CentOS7镜像安装好虚拟机 http://t.zoukankan.com/onlymate-p-9837651.html这个链接的镜像是7.0的,我 ...
- allure安装成功后,执行未生成报告解决
在搜索了很多方法尝试后,执行依然没有生成测试报告,在尝试在pycharm里面修改配置解决了: file>setting>tools>Python integrated tools&g ...
- Mac如何卸载软件 Mac如何删除软件
初次接触Mac苹果电脑的用户可能不知道如何卸载已经装好的应用软件,之前有给大家介绍Mac如何安装软件,现在教大家如何卸载软件,其实非常简单,让我们看看吧: 1.首先我们打开Finder,就是我们Doc ...
- 【ADB命令】安装app
在电脑上安装以下指令 adb install app的文件位置
- Java+selenium自动爬取网站内容并写入本地
目的:本文主要描述如何使用Java+selenium爬取58同城招聘页,并记录指定职位的招聘公司名保存到本地 一.首先创建一个maven工程,配置依赖包 1 <dependencies> ...
- nodejs redis执行lua脚本
const Redis = require("ioredis"); const redis = new Redis({ port: 6300, // Redis port host ...
- git常用命令查询手册
默认已经连接到远程仓库的情况下 本地文件夹初始化成git仓库.提交本地仓库并添加注释 git init git add 文件1(文件夹1) 文件2(文件夹2)... git commit -m &qu ...
- kafka消费者3种分配策略
0.10.2.1 版本的Kafka 有两种分配策略,由消费者测的参数partition.assignment.strategy来控制. RoundRobinAssignor分配策略 RangeAssi ...
- fiddler 实现跨域
static function OnBeforeResponse(oSession: Session) { ... if(oSession.uriContains("要处理的url" ...
- 【Android HttpClient引入】感慨下自己看的Android教程有点老了
教程看到使用HttpClient,发现没有继承该类. 原因是API23即在Android 6.0(API 23) 后,Google已经移除了Apache HttpClient 相关类,推荐使用Http ...