Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要一个大的二维数组,比如
int myArray[10000][2];
有人告诉我这样构建的数组是不合适的,应该使用malloc在堆中构建。有人可以告诉我如何做到这一点吗?谢谢!
#include <stdlib.h>
//分配
int **vv = malloc(2 * sizeof(int *)); for(int i = 0; i < 2; i++) vv[i] = malloc(10000 * sizeof(int));
//自由的
for(int i = 0; i < 2; i++) free(vv[i]); free(vv);