【发布时间】:2014-03-06 12:59:53
【问题描述】:
这是用于打印尝试中所有单词的功能。但有时我会出错。不明白哪里出错了???请帮助我..非常感谢。
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]);
}
}
}
【问题讨论】:
-
您遇到了什么具体错误?另外,您能否正确格式化您的代码(添加缩进、cmets、空格等)?
-
typedef int boolean;!你为什么要这么做? -
你能指定哪个错误?
-
这似乎是逻辑错误我的意思是有时所有输入的单词都会通过调用此函数来显示有时不是
-
其实我想知道如何以递归的方式去打印里面的所有单词。
标签: c data-structures recursion struct recursive-datastructures