#include <stdio.h>
typedef struct
{ int occurrence
char charArray[101];
}Wordy;
int comparing(const void *a, const void *b)
{
//....
}
int main(void)
{
int i=0;
Wordy array[99999];
//.....
return 0;
}
*/
This program reads words from a file, then the occurrence of the word is calculated. Everything works, but I don't think the qsort function is working correctly in the comparing function. It's suppose to sort array in terms of its occurrence. (Finding its occurrence is correct.)
My sample text file:
zero one
two zero
three three
Output:
Before: zero one two three
After: one two three
(notice that zero is missing after sorting)
array[1].wordandarray[0].wordbutWordyhas no member namedword, does this compile?