简易C程序错误

时间:2016-10-10 22:57:33

标签: c visual-studio visual-studio-2012 compiler-errors

我正在编写一个非常简单的程序来显示一个类的模拟天气数据,我无法弄清楚为什么visual studio会一直给我一个错误

错误在温度方向告诉我:错误C2440:' =' :无法转换为' double(__ cdecl *)(void)'到'加倍

我失去了请帮助

void DisplayWeatherData(void)
{
    double temperature,humidity,pressure,windspeed,direction,bt,bp,bw;

    temperature = GetTemperature;
    humidity = GetHumidity;
    pressure = GetPressure;
    windspeed = GetWindspeed;
    direction = GetWindDirection;
    bt = (temperature * 9.0 / 5.0) + 32.0;
    bp = pressure * KPATOINHG;
    bw = windspeed * KMTOMPH;


    printf("\nTemperature: %4.1lf C\tHumidity: %3.0lf%%\tPressure: %4.1lf kPa\n",temperature,humidity,pressure);
    printf("Windspeed: %3.0lf km/hr\tDirection: %3.0lf Degrees\n\n",windspeed,direction);

    printf("\nTemperature: %4.1lf F\tHumidity: %3.0lf%%\tPressure: %4.1lf inHg\n",bt,humidity,bp);
    printf("Windspeed: %3.0lf mph\tDirection: %3.0lf Degrees\n\n",bw,direction);


}

double GetTemperature(void)
{
return 25.1;
}
double GetHumidity(void)
{
return 55.4;
}   
double GetPressure(void)
{
return 101.7;
}   
double GetWindspeed(void)
{
return 15.5;
}   
double GetWindDirection(void)
{
return 320.0;
}

1 个答案:

答案 0 :(得分:0)

你错过了括号:

temperature = GetTemperatur;
humidity = GetHumidity;
pressure = GetPressure;
windspeed = GetWindspeed;
direction = GetWindDirection;

应该是这样的:

temperature = GetTemperature();
.//same
.//same
.//same
direction = GetWindDirection();