注册 登录
编程论坛 数据结构与算法

将哈夫曼树输入到文件时,文件为什么显示出来的是一串数字(怀疑是地址)?

丘汤媚 发布于 2014-12-03 19:16, 785 次点击
我想将哈夫曼树中每个节点存的字符输入到文件里,但为什么不管我输入的是什么,都显示8个数字呢?难道我输进去的是地址?
下面的代码有没有问题啊,求大神指教,谢谢!!
void display_file(char *filename,HuffMan *Hu_head) //将建好的哈夫曼树存放在hfmTree文件中。
{
    ofstream outfile(filename,ios::out);
    if(!outfile)
    {
        cerr<<"open error!"<<endl;
        exit(1);
    }
    outfile<<Hu_head;
    cout<<endl;
    outfile.close();
}

ofstream &operator <<(ofstream& out,HuffMan *&Hu_head) //重载<<,将建好的哈夫曼树存放在hfmTree文件中。
{

    HuffMan *current;
    current=Hu_head;
    if(!Hu_head)
        out<<current->ch;        
   out<<current->lchild;
   out<<current->rchild;
   cout<<endl;
   return out;
}
0 回复
1