Hi,
Here's a part of the code:
#define S 1000 /* rows */
#define T 200 /* columns */
int main()
{
int n, i, j;
float **x;
x=(float**) malloc (T*sizeof(float*));
for(i=0; i<T; i++)
x[i]=(float*) malloc (S*sizeof(float));
memset(x, 0, sizeof(x[0][0])*S*T);
return 0;
}
This was compiled well (gcc) and had no troubles running (a.out).
But when I added the following simple thing, just to make a small check:
printf("\n%g\n", x[0][0]); /* or some other cells in this array */
Compilation was still ok, but I got a segmentation fault.
BTW -
I tried another almost identical version of the malloc, instead of what's above:
x=(float**) malloc (T*sizeof(float));
for(i=0; i<T; i++)
x[i]=(float*) malloc (S*sizeof(float));
(which is the correct version? both went fine anyway through compilation and run)
Any kind of help would be great :)
Many thanks!
Michal