I know that the result of
int *x = malloc(sizeof(int)*100);
and
int x[100];
is same,but the first one is allocating heap memory,and second one is allocating stack memory.
Now i need to create a huge array(about 10000 element,not in a pattern),I think malloc() is more suitable.
But when i ready to initialize the array, I face a problem. I cannot use any looping to init the array,how can I init an array that created by using malloc ,just like using
int x[100] = {1,2,3,4,......,6,7,5};
x[0]=0; x[1]=1; x[2]=2;...Look ma, no loops!int *x = malloc(sizeof(int)*100);andint x[100];are not the same, and not just because of stack and heap.