2016-10-10 44 views
-1

我寫一個非常簡單的程序,一類顯示模擬的天氣數據,我不能弄清楚爲什麼Visual Studio中不斷給我一個錯誤易C程序錯誤

誤差溫度通過方向的告訴我:錯誤C2440: '=':不能從轉換 '雙(__cdecl *)(無效)' 到 '雙'

IM迷路了,請幫

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

簡單錯字errors.'GetTemperature' - >'GetTemperature()'' – kaylum

+1

溫度= GetTemperature;' - >'溫度= GetTemperature();'等上。 –

回答

0

您在此無緣括號:

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

它應該是這樣的:

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