warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&f);
这个是C语言当中常见的错误,意思是
对于输入的scanf参数的内容,没有进行类型判断,所以才会产生这个问题.
解决方法:
1、添加if判断方式

1 if(scanf("%d",&a)==1){
2 // 成功继续执行其他代码
3 }
2、其它类型判断方式扩展

1 if(scanf("%d",&a)==1){
2 // 成功继续执行其他代码
3 }
4
5 if(scanf("%f",&a)==1){
6 // 成功继续执行其他代码
7 }
8
9 if(scanf("%s",&a)==1){
10 // 成功继续执行其他代码
11 }
3、参数个数扩展

1 scanf("%d",&a);正确输入则返回1;
2 scanf("%d%d",&a,&b);正确输入,则返回2,以此类推;
即:如果输入一个参数,就判断结果是否==1,如果输入两个参数就判断是否==2,如果输入三个参数就判断==3,以此类推

1 if(scanf(“%d %d",&a,&b)==2){
2 // 功能代码
3 }
4
5 if(scanf(“%d %d %d",&a,&b,&c)==3){
6 // 功能代码
7 }
warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&f);的更多相关文章
- a.c:5:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wun
PTA做题时出现的错误,用if括起来就没有了. if(scanf("%d",&a)){}; 其实并不是这里有问题,如果你的输出有问题,他就会鸡蛋里挑骨头的先显示这个错误.
- react native 打包Ignoring return value of function declared with warn_unused_result attribute
从 github上下载 项目 用于学习查看别人的代码, 当执行完npm install 用xcode 打开 发现俩个错误提示Ignoring return value of function dec ...
- f-stack中nginx配置后make出现error: ignoring return value of ‘ftruncate’
问题 Nginx 配置后 make 出现error: src/os/unix/ngx_process_cycle.c: In function 'ngx_start_worker_processes' ...
- 解决Undefined symbols for architecture x86_64: 报错 和 ld: warning: ld: warning: ignoring file警告
出现这种错误的情况: 用iphone5模拟器编译程序正常, 用iphone5s以上的模拟器编译出现Undefined symbols for architecture x86_64: 报错 和 ld: ...
- Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
1 启动hbase的时候爆出警告 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; suppor ...
- warning: ignoring option PermSize=256m; support was removed in 8.0
使用jdk1.8后,控制台出现下面提示信息: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; sup ...
- 静态库引入引起的错误解决方案,ld: warning: ignoring file ”…/XXX.a”, file was built for archive which is not the architecture being linked (armv7): “…/XXX.a” Undefined symbols for architecture armv7: "_OBJC_CLASS_$
想目中不免会引入一些静态库,可是有时加入'.a'文件后编译便会报以下错误 ld: warning: ignoring file ”…/XXX.a”, file was built for archiv ...
- iOS编译错误#ld: warning: ignoring file# 之 Undefined symbols for architecture x86_64 - ld: symbol(s) not found for architecture x86_64
ld: warning: ignoring file xxxPath/libbaidumapapi.a, missing required architecture x86_64 in file xx ...
- Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
目录 启动一个Java Standalone程序时报错 解决办法 解释 参考 启动一个Java Standalone程序时报错 Java HotSpot(TM) 64-Bit Server VM wa ...
- bug处理记录:Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=512M; support was removed in 8.0
1. 报错: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=512M; support was removed ...
随机推荐
- #分治 or 线段树+单调栈#CF526F Pudding Monsters
题目 给定一个 \(n \times n\) 的棋盘,其中有 \(n\) 个棋子,每行每列恰好有一个棋子. 求有多少个 \(k \times k\) 的子棋盘中恰好有 \(k\) 个棋子. 分析 先将 ...
- #莫比乌斯反演#ZOJ 3435 Ideal Puzzle Bobble SP7001 VLATTICE
ZOJ 3435 Ideal Puzzle Bobble SP7001 VLATTICE - Visible Lattice Points(洛谷题目传送门) SP7001 VLATTICE - Vis ...
- 探索基于WebRTC的有感录屏技术开发流程
第一章:技术原理 WebRTC(Web Real-Time Communication)是一种开放源代码项目,旨在通过浏览器之间的点对点通信实现实时音视频通信.WebRTC利用JavaScript A ...
- 掌上新闻随心播控,HarmonyOS SDK助力新浪新闻打造精致易用的资讯服务新体验
原生智能是HarmonyOS NEXT的核心亮点之一,依托HarmonyOS SDK丰富全面的开放能力,开发者只需通过几行代码,即可快速实现AI功能.新浪新闻作为鸿蒙原生应用开发的先行者之一,从有声资 ...
- AI数字人互动大屏:如何改变我们的生活?
随着科技的飞速进步和人工智能技术的日益成熟,智能制造正在成为推动制造业转型升级的核心力量. 互动数字人具有强大的情感分析能力,可以根据观众的表情.语气等实时反馈,作出恰当而富有情感的回应.这不仅让每一 ...
- 报表如何批量导出成 excel 文件
需求说明 报表展现后可以通过工具栏中的导出按钮将当前展现的报表导出成 excel 文件,但是在实际使用中通常会要求报表不需要展现,直接通过一些操作将报表导出成 excel 文件,并且往往会要求批量导出 ...
- nginx重新整理——————http请求的11个阶段中的preaccess[十四]
前言 简单整理一下preaccess. 正文 主要是介绍一下上文提及到的limit_req以及limit_conn. 里面是http_limit_conn_module 默认编译进去. 生效范围: 全 ...
- nginx重新整理——————http 模块中的请求过程[十一]
前言 简单介绍一下http的一些指令. 正文 一般http的嵌套规则是这样的: http{ upstream{} split_clients {} map{} gep{} server{ if(){} ...
- WAF网站访问限制
请参考:https://www.cnblogs.com/yangyangblog/p/14930159.html 文件下载的地方可以网络搜索,这里提供IIS7 WINDOWS64位版本:https:/ ...
- 聊聊 Linux iowait
哈喽大家好,我是咸鱼. 我们在使用 top 命令来查看 Linux 系统整体 CPU 使用情况的时候,往往看的是下面这一列: %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 ...