由于某些原因,我在此处收到了分段错误。我不知道为什么。任何帮助?无法解释的分段错误
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
你有没有intialise指针世界? – 999k 2013-03-11 05:51:48