<分区>
我有一个在二维数组中存储信息的结构:
struct slopes {
int size;
int ** slope_array;
};
我为结构分配了所需的内存(数组的维度为 s*s):
struct slopes * slope=malloc(sizeof(struct slopes));
slope->size=s;
slope->slope_array=malloc(sizeof(int *)*s);
int i;
for(i=0;i<s;i++) {
slope->slope_array=malloc(sizeof(int)*s);
}
但是像这样的行似乎会引发段错误:
slope->slope_array[0][0]=3;
有人能看出我做错了什么吗?