#Array filling problem
Hello,
I could really use some help here with my frustrations. Please! I put
892 records of size struct record in a file "Names", which I want to fill
an array in my real program. I wrote the small program below to check if
everything will load right at run time and guess what?? I keep getting a
GURU 0005 "Memory list damaged" message. This program prints out about 30
names and then hello guru. Thank-you for the help.
Henry Williams
#include <stdio.h>
struct record{
char name[35];
int family;
};
main ()
{
FILE *in;
struct record box;
int a = 0, n = 1;
char array [892][35];
if (( in = fopen ("Names", "r")) == (FILE *) NULL ){
fprintf (stderr, "\n Couldn't read Name file!\n");
exit(10);
}
while (n == 1){
n = fread ((char *) &box, sizeof (struct record), 1, in );
strcpy (array[a], box.name);
printf (" %-35s %d\n", array[a], box.family);
++a;
}
printf (" A = %d N = %d\n", a, n);
fclose (in);
}