Trying to decpmpress a coded file
i am writting a code to decompress a huffman file and i am a little bit confused.I am using the amount of charracters that was written into file to help me determine when to stop reading.I am a little bit confused because it seems like a maze
Code:
void HuffmanENcodding :: decompressFile(ifstream &file){
file.open("Thecompressed.txt");
string text;
unsigned char byte; //used to store a byte when read
int length=8;
int shift=7;
int direction; //used to determine whether to go left or right
Node *root=new Composite(); //gets the top of my tree
root=getRoot();
for(int i=0;i<characterslenght;i++){
if(length==8){
byte=file.get();
}
while(length)
direction=(byte>>shift) &1; //getting the bit starting from the msb
getchild(root,direction);
}
}
above is a sample code