struct output { int freq; char *fname; }; void print_search(Node *head, char **filenames, char *word) { Node *cur = head; int count; int j; int i; struct output **outputarray= NULL; while(cur != NULL) { if (strcmp(cur->word,word)==0){ for(i = 0; i < MAXFILES; i++) { if(filenames[i] != NULL) { outputarray = (struct output **)realloc(outputarray, (count + 1) * sizeof(struct output *)); outputarray[count] = (struct output *)malloc(sizeof(struct output)); outputarray[count]->freq=cur->freq[i]; outputarray[count]->fname=filenames[i]; count++; } } } cur = cur->next; } qsort(outputarray, count, sizeof(*outputarray), cmpr); for(j=0; jfreq, outputarray[j]->fname); }