is there any problem with this code . i can't decode huffman with it. fault : segmentation fault (core dumped)
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;
}
}
}