Ç - 错误:忽略scanf函数的返回值? [英] C - error: ignoring return value of scanf?

查看:1037
本文介绍了Ç - 错误:忽略scanf函数的返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只有几天到C编程,因此,我不太清楚有什么不对的code:

 的#include<&stdio.h中GT;    INT主(INT ARGC,CHAR *的argv []){    双方诠释;    的printf(请输入三个边长:\\ n);
    scanf函数(%d个,&安培;侧);    返回0;    }

我得到的错误是:scanf函数的忽略返回值

帮助请!


解决方案

这是从它执行的任务(太严格设置)停止你的编译器警告。检查scanf()的函数的返回值,错误和警告应该消失。


  

返回值


  
  

    

在成功,该函数返回的项目数
    成功读取。此计数可以匹配的预期数量
    读数或更少,甚至是零,如果一个匹配失败发生的情况。在里面
    输入失败的情况下,之前的任何数据可以被成功读取,
    返回EOF。


  

I'm only a few days into C programming and as such, am not quite sure what's wrong with this code:

    #include <stdio.h>

    int main(int argc, char * argv[]) {

    int sides;

    printf("Please enter length of three sides :\n");
    scanf("%d", &sides);

    return 0;

    }

The error I'm getting is: ignoring return value of scanf

Help pls!

解决方案

It's a warning that stops your compiler from performing it's task (too strict settings). Check the return value of the scanf() function for errors and the warning should disappear.

Return Value

On success, the function returns the number of items successfully read. This count can match the expected number of readings or fewer, even zero, if a matching failure happens. In the case of an input failure before any data could be successfully read, EOF is returned.

这篇关于Ç - 错误:忽略scanf函数的返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆