未初始化的局部变量,找不到错误

时间:2015-06-14 17:15:00

标签: c initialization

#include <stdlib.h>
#include <stdio.h>
#pragma warning (disable : 4996)
int main()
{
    double F, C;

    printf("Enter temperature reading > \n");
    scanf("%lf", C);

    F = 32 + ( C * (180.0/100.0));

    printf("\n The temperature reading in Fahrenheit is : %.1lf", F);

    system ("pause")
}
  

错误C4700:未初始化的局部变量'C'使用

我无法在程序中找到错误。

1 个答案:

答案 0 :(得分:1)

F正在设置一个值,因为它后跟一个=符号,而C正在将其值作为函数中的参数传递;您必须将其值设置为0

其次scanf("%lf", C)应为scanf("%lf", &C)

#include <stdlib.h>
#include <stdio.h>
#pragma warning (disable : 4996)
int main()
{
    double F, C = 0.0;

    printf("Enter temperature reading > \n");
    scanf("%lf", &C);

    F = 32 + ( C * (180.0/100.0));

    printf("\n The temperature reading in Fahrenheit is : %.1lf", F);

    system ("pause");
}