I keep trying different ways of writing a compare function but when I run the program I keep getting a seg fault at the qsort function call.

I have:
Code:
typedef struct
{
    int count;
    char *data;
}Wordrec;

int comp(const void *a, const void *b)
{
    const Wordrec **l = (const Wordrec **) a;
    const Wordrec **r = (const Wordrec **) b;
    
    return strcmp((*l) -> data, (*r) -> data);
}
And the qsort call:
Code:
qsort(record, numwords, sizeof(Wordrec), comp);
record is a pointer to a pointer (**record), used like a dynamic array and numwords is the number of words/records.

This is homework. I'm supposed to read in a text file, read out a text file with all the lines a certain size or less, and read out a sorted text file that has one occurrence of each word (without worrying about punctuation) and the number of times that word occurred.

Everything but the sorted part is done, I just can't seem to get the qsort function to work right.

Any help will be greatly appreciated. Thank you.