如何创建一个非常大的数组?好吧,我无法创建一个大小为 INT_MAX 的数组。如何实现这一点。?
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define SIZE 2147483647
int main() {
int *array;
unsigned int i;
array = malloc(sizeof(int) * SIZE);
if(array == NULL) {
fprintf(stderr, "Could not allocate that much memory");
return 1; }
for(i=0; i<1; i++) {
array[0] = 0;
}
free(array);
}