我定义了以下结构:
typedef struct word {
const char *str;
int freq;
int edit_list;
} Word;
在我的main
函数中,我使用预定义的向量来存储Word
类型的集合(如上面的结构中所定义)。名为corrections
的Vector已经定义,并且还拥有它自己的迭代器。
for(const Word *key = cvec_first(corrections); key != NULL; key = cvec_next(corrections, key)) {
print("%s\n", key->str);
print("%d\n", key->freq);
print("%d\n", key->edit_dist);
}
for循环遍历单词集合,我打算打印出Word
结构的每个值。但是,只有str
类型才能正确打印出来,而freq
和edit_dist
会打印出垃圾值。