Please allow me to make a beginner's question. I'd like to declare an array of structures for holding data of a worksheet:
and I got an error message "Segmentation fault (core dumped)" when MAXROW=500. (size of struct row = 5244byte)Code:struct row {int name; int age; int dob; ...(many entries)...}; main() {struct row worksheet[MAXROW]; ....}
As I did not get the error when MAXROW=10, the problem seems to be an available memory space, but I could also make it without the error under the following two versions of codes:
version1 (MAXROW=500)
version2 (MAXROW=500)Code:struct row {int name; int age; int dob; ...(many entries)...} worksheet[MAXROW]; main() {....}
Could anyone please point out what's wrong in the first code?Code:#include <stdlib.h> struct row {int name; int age; int dob; ...(many entries)...}; main() {struct row *worksheet; worksheet = calloc(MAXROW, sizeof(struct row)); ....}



LinkBack URL
About LinkBacks



