首页 > 解决方案 > 由于警告 C6031(“忽略返回值:'scanf'),Visual Studios 不会编译代码

问题描述

我很新,几周前才开始学习如何编码。我下载了 Visual Studio 并尝试将其用作编辑器和 C 编译器。我制作了一个程序并尝试编译它,但由于此 C6031(“忽略返回值:'scanf')警告,它不会。我尝试在 C 编译器上在线编译它并且它有效。不知道如何解决这个问题。 Visual Studios (v 2019) 有问题吗?这是我的代码。

#include<stdio.h>
#include<math.h>
int main(void)
{
    // Define variables
double x, answer;
    // Define the value we will find the sin of
printf("Enter a value for x between (0, 1): ");
    scanf("%lf", &x);
    // Calculate the sin of value
    answer = sin(x);
    if ((x >= 0) && (x <= 1)) {
            // Display answer
        printf("\nThe sine of %lf is %lf", x, answer); }
    else
{
        printf("Value is not within (0, 1) range.");
}
return 0;
}

标签: cvisual-studiovisual-studio-2019compiler-warnings

解决方案


推荐阅读