// 动态创建gridSize行,gridColSize列的二维数组
int gridSize = 3;
int gridColSize = 5;
int **grid = (int **)malloc(sizeof(int *) * gridSize);
for (int i = 0; i < gridSize; i++) {
grid[i] = (int *)malloc(sizeof(int) * gridColSize);
}
// 释放资源
for (int i = 0; i < gridSize; i++) {
free(grid[i]);
}
free(grid);
动态创建二维数组
最新推荐文章于 2022-01-14 07:48:46 发布