Public feed #378730

Untitled

public text v1 · immutable
Raw Edit
·published 2007-03-02 18:48 UTC
rendered paste body
    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-1, sizeof(struct output) , cmpr);
        for (j=count-1;outputarray[j]!=NULL;j--)
        printf("%d %s",outputarray[j]->freq, outputarray[j]->fname);