2017-06-03 77 views
-4
int main(int argc, char **argv) { 
    float *rainfall; 
    float rain_today; 
    // rainfall has been dynamically allocated space for a floating point number. 
    // Both rainfall and rain_today have been initialized in hidden code. 
    // Assign the amount in rain_today to the space rainfall points to. 

    return 0; 
} 

大家好。這是一個非常基本的問題,但我還沒有找到解決方案。 是不是隻是動態內存指針

rain_today = *rainfall 
+1

如果有的話是相反的。 – kaylum

回答

0

rain_today = *rainfall;號將採取由rainfall指出的值,並把它放在rain_today(理想NULL)。

你被要求做的是把的rain_today值到由指針rainfall

指向的空間是:

*rainfall = rain_today \\the value of rain_toady is COPIED to the space pointed by rainfall 

或者你可以這樣做:

rainfall = &rain_today \\rainfall points at the memory location of rain_today