Hi friends i wrote a C program for solving Poisson equation over a square plate.Where we have to define the grid size.i have defined several 2-d arrays in program to store the values. the problem size is quite big so i have to define the size of array of order of 10000x10000... but when i compile the program. it shows some error. how can i use such big arrays without much trouble.
The size of each integer is 4bytes under windows and the C Compiler generally allocates memory in RAM. So , for now ur allocated memory is 40,00000 bytes and you do not have that much size of RAM installed in ur CPU. As a result , ur PC show error or does not responds.
using tc its 2bytes for integers and in gcc its 4 bytes but it would be better if you use dynamic allocation for doing it so.
I would rather go with a dynamically allocated array, that is, instead of double array[MAX][MAX]; do something like Code: double *array[MAX]; int i; for(i = 0; i < MAX; i++) { array[i] = (double*) malloc(MAX * sizeof(double)); /* Insert here some check if the malloc went OK, be prepared for an IMPROBABLE out of memory situation */ } Now you can use array[j] exactly the same way as before, it just works a bit different way internally: the program looks at array, which is a pointer on double, so it can be used as an array of doubles, and then addresses the j-th element thereof. You must not forget to deallocate all this memory at the end of your program, though: Code: for(i = 0; i < MAX; i++) { free(array[i]); } Hope this helps! [If not, you can try copying the error message here so that we can tell how to fix it.] PS: You should not be limited by your computer memory too much. A 10000 x 10000 array of doubles still takes less than 1 GB. And virtually every computer nowadays uses virtual memory which is swapped on your hard drive. Rest assured that many other programs use MUCH more memory and work well.