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
答案 0 :(得分: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