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 ...
随机推荐
- kibana启动时报错:Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [999]/[1000] maximum shards open
解决方案: curl -XPUT -H "Content-Type:application/json" -d '{"persistent":{"clu ...
- 实验:STM32-ARDUINO-ESP01采用AT指令,通过MQTT连接上ONENET
1.硬件准备 要求:STM32支持Arduino. 2.程序逻辑结构 3.主流程状态机 4.测试数据抓图 5. 关键程序代码 unsigned char g_ArrTemp[1024]; int AT ...
- windows 和 linux 之间的文件传输操作
参考:http://www.jb51.net/article/123378.htm 本文介绍,如何实现 windows 主机与 linux 虚拟机之间的文件传输. 一.获取虚拟机 IP 地址 要实现 ...
- RabbitMQ宕机了怎么办?
RabbiMQ宕机会导致消息丢失! 解决办法:可以做消息持久化. 非持久化消息:只有非持久化消息在RabbitMQ宕机时会发生消息丢失. 持久化消息:持久化的消息会在接收后被保存到磁盘中,所以Rabb ...
- Linux常用指令1
1.文件和目录的相关指令: ·cd:打开 ·pwd:查看当前所在的目录 ·mkdir:新建目录 ·rmdir:删除目录 ·ls:文件和目录查看 ·cp:复制 ·rm:删除 ·mv:移动 2.文本文件内 ...
- python 安装步骤
1.这个安装方法不需要配置环境变量 2. 3. 4.进入cmd,输入python -v
- Flutter 新建项目
一.打开VSCode,点击侧边栏扩展按钮,搜索flutter,安装Flutter和Dart 二.按command+shift+P,输入flutter,选择Flutter:New project,新建项 ...
- Day15-static、抽象类、接口、内部类
static.抽象类.接口.内部类 一.static关键字详解 1.静态的变量/方法 package Demo02; //static public class Student { private s ...
- c++标准官网
gcc官网: https://gcc.gnu.org/ c++参考手册: https://en.cppreference.com/w/cpp c++教程网站: https://www.learncpp ...
- 如何卸载inventor 2023?怎么把inventor彻底卸载删除干净重新安装的方法【转载】
inventor 2023卸载重新安装方法,使用清理卸载工具箱完全彻底删除干净inventor 2023各种残留注册表和文件.inventor 2023显示已安装或者报错出现提示安装未完成某些产品无法 ...