此代码是否有任何问题。我不能用它解码霍夫曼。 故障:分段故障(核心已转储)
char * real_bin =“ 100101111101001100”
struct tree
{
int fre;
char c;
struct tree *left;
struct tree *right;
};
typedef struct tree tree;
void decode_huffman(tree *root, char *real_bin)
{
tree *p = root;
int m = strlen(real_bin);
for (int i = 0; i < m; i++)
{
if (real_bin[i] == '0')
{
p = p->left;
}
else
{
p = p->right;
}
if (p->c != '\0')
{
printf("%c\n", p->c);
p = root;
}
}
}
答案 0 :(得分:0)
好吧,如果您对编码非常确定,然后选择树形结构,则应该以这种方式调整代码
source = new EventSource(addr);
source.onopen = function open() {
console.log('Connection established.');
};
source.onmessage = (e) => {
console.log(e.data)
}