How can I malloc a struct array inside a function? Code works otherwise
问题 I'm trying to create a function that creates a variable sized 2D funct array. I'm using the following code, which seems to work just fine on its own: typedef struct { //Starter Properties int TypeB; int TypeF; int TypeW; //Randomized Properties int RandB; int RandF; int RandW; //Derived Properties int Speed; } MapTileData; MapTileData **Map; int i, x=5, y=5; //Allocate Initial Space Map = (MapTileData**)calloc(x, sizeof(MapTileData)); for(i = 0; i < x; i++) { Map[i] = (MapTileData*)calloc(y,