-1

this is the function witch is used to print all words in the tries .But some time I am getting error .Can't understand where went wrong ???please help me..thanks a lots.

typedef int boolean;
typedef struct test_struct test_struct_t;
struct test_struct {
    boolean end;
    int freq;
    char* word;
    test_struct_t *next;
    test_struct_t *child[26];
};
typedef struct trie trie_t;
struct trie {
    struct test_struct *root;
    int count;
};
void printContent(test_struct_t *head) {
    for(int i=0;i<26;i++) {
        if(head->child[i]->w!='1') {
            if(head->child[i]->end==TRUE) {
                printf("%s (%d)\n",head->child[i]->word,head->child[i]->freq);
            }
            printContent(head->child[i]);
        }
    }
}
ajay
  • 8,550
  • 7
  • 34
  • 67
GPrathap
  • 5,786
  • 6
  • 54
  • 75

1 Answers1

0

in this line if(head->child[i]->w!='1'){, why there is a w?

maybe you can try this: if( (head->child[i] != null) && head->child[i]->word!='1'){

BlackMamba
  • 9,026
  • 6
  • 36
  • 58
  • struct test_struct { boolean end; int freq; char* word; char w; test_struct_t *next; test_struct_t *child[26]; }; here w is the place where character is stored. – GPrathap Feb 09 '14 at 10:14