Hi I'm trying to store some words from an input file to an array, but I keep getting segmentation faults.
The input text file looks something like this
135 hello
124 help
1 first
each word is separated by a tab after the number

The following are some of my codes that are relevant:

typedef struct mydata Mydata;
struct mydata {
int key[5000];
char *name;
};

void inputfile() {
FILE *input;
int i, key;
char name[100];
Mydata array;

input = fopen ("testdata.txt", "r");

for(i=0;i<=MAX && !feof(input); i++)
{
fscanf (input, "%d%s", &key, &name);
array.key[i] = key;
array.name[i] = strdup (name);
}

now say, if I want to do
printf ("%d%s", array.key[0], array.name[0]);
I get segmentation fault

the problem here I think it's I've used strdup wrong, or storing the words in wrong. As it can store numbers with no errors.

Can someone suggest to me what I'm doing wrong? Have I not assigned spaces for array.name correctly?

Thanks in advance,
Will