由于某种原因,我在这里遇到了分段错误。我不知道为什么。有什么帮助吗?
typedef struct gw_struct{
int pop;
int col;
int row;
struct district ***gw;
struct person **people;
};
typedef struct gw_struct *GW;
然后在一个函数中......
GW world;
struct district ***array = malloc(nrows*sizeof(struct district**));
int i, j;
for (i = 0; i < nrows; i++)
{
array[i] = malloc(ncols*sizeof(struct district*));
for (j = 0; j<ncols; j++)
{
array[i][j] = malloc(sizeof(struct district));
}
}
world->gw = array; //this is the line that gives the seg fault