【发布时间】:2017-06-01 22:34:43
【问题描述】:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) {
float **daily_rainfall;
float new_rainfall;
// daily_rainfall has been assigned an array of 12 float arrays. Each element of the array
// has been initialized to point to an array of 31 floats. This structure represents a year's
// worth of rainfall.
//
// new_rainfall has been intialized to some hidden value.
//
// Set the float corresponding to April 12th (the 12th day of the 4th month)
// to equal the value currently stored in new_rainfall.
return 0;
}
我是 c 的新手。我试图弄清楚,但没有成功。
(*daily_rainfall)[4][12] = new_rainfall;
我认为这是有道理的,但我遇到了错误。
【问题讨论】:
-
你必须使用 malloc() 还是可以使用数组?标题写着“动态”。
-
另外,c 是基于 0 的,所以第 4 个月是 MAY。
-
@JustinJ。哦,是的。应该是 daily_rainfall[3][11] = new_rainfall;谢谢!
-
如果您需要有意义的帮助,请说明您如何分配数组,如何将其分配给
float **daily_rainfall;,并描述您遇到的错误。