Big structure + file pointer = segmentation fault
Hi there,
I need to use a big structure (fixed size), with multiple file operations.
I could isolate the problem, contained inside the code below.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
typedef struct library59k {
int numModel;
char combination[6];
double rmsd_ext;
double rmsdTotal;
double det;
double coord[28][3];
} lib;
int main()
{
lib member[59049];
FILE *out;
out = fopen("output", "w");
if (out==NULL)
{
printf("cant write file.\n");
exit(3);
}
return 0;
}
The program compiles, but when I execute it, I get segmentation fault error, unless that I reduce the size of the structure.
Is there a size restriction for structures?
I guess it probably has to do with the size of the coord[28][3] pointer.
I'm using gcc 4.4 compiler.
thanks in advance for any help.