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
最佳答案
没有。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