please, could you help me with qsort of struct of strings? I need to sort alphabeticaly words in dictionary. Problem is, that it throws me Segmentation fault... Here are my structs:
typedef struct {
int length;
char *data;
} Word;
typedef struct {
int length;
int index;
Word *data;
} Dictionary;
Here is compare function:
int compare(const void *a, const void *b)
{
return strcmp (((Word *)a)->data, ((Word *)b)->data);
}
And here is qsort implementation:
qsort(&dictionary, dictionary.index, sizeof (Word *), compare);
Thank you very much for your help.
lengthandindexinDictionary.