multiple arrays
Hi all,
im stuck again with something simple. there is a 4-dimensional array, but it gives segmentation fault when one of dimensions is big like 30000. dont know why :"( #include <time.h> #include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #define N_I 30000 int main (int argc, char* argv[]) { printf("!!!!1 \n"); int m[18][30][N_I][4]; int i,j,k,l; for (i=0;i<18;i++) for (j=0;j<30;j++) for (k=0;k<N_I;k++) for (l=0;l<4;l++) { m[i][j][k][l]=i+j+k+l; printf("%d\n",m[i][j][k][l]); } return 0; } it works fine when N_I=300; but crashes when N_I=30000; thank you |
ups, i think i got it, i run in on cluster and since big arrays take a lot of space may be it was not allowed to take it, but when i run it on my laptop it works.
sorry |
You cant use that many loops. Your program crashes. Depending on how much your RAM capacity is, there are limitations.
Once I was trying to create a word combination list, I used multiple for loops but my core got dumped. Its way more complex than you could understand. :D |
Quote:
Code:
ulimit -s unlimited Next time, if you require a large array (single or multi-dimensional), allocate it on the heap rather than declare it on the stack. |
thank you!!!
|
All times are GMT -5. The time now is 10:10 AM. |