The problem is that ia
and ib
are pointers to const struct word
. To access a member of a structure true a pointer to it we use arrow (->
)and not a dot .
.
Another thing make sure to spell the structre name when you declare ia
and ib
the same way as you declared it in the above.
So you code whould be:
struct word
{
char wordy[100];
int count;
};
int compare(const void* a, const void* b)
{
const struct word *ia = (const struct word *)a;
const struct word *ib = (const struct word *)b;
if(ia->count > ib->count)
return 1;
else if(ia->count == ib->count)
return 0;
else
return -1;
}