Click here to Skip to main content
15,894,539 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get CPU_Type in c++? Pin
Rajesh R Subramanian3-May-11 18:48
professionalRajesh R Subramanian3-May-11 18:48 
AnswerRe: How to get CPU_Type in c++? Pin
Stefan_Lang3-May-11 20:42
Stefan_Lang3-May-11 20:42 
QuestionHow to make CStatusBarCtrl::SetBkColor work? Pin
zhong_min3-May-11 17:15
zhong_min3-May-11 17:15 
AnswerRe: How to make CStatusBarCtrl::SetBkColor work? Pin
Hans Dietrich3-May-11 18:16
mentorHans Dietrich3-May-11 18:16 
GeneralRe: How to make CStatusBarCtrl::SetBkColor work? Pin
zhong_min3-May-11 18:51
zhong_min3-May-11 18:51 
GeneralRe: How to make CStatusBarCtrl::SetBkColor work? Pin
Hans Dietrich3-May-11 18:57
mentorHans Dietrich3-May-11 18:57 
GeneralRe: How to make CStatusBarCtrl::SetBkColor work? Pin
zhong_min3-May-11 19:23
zhong_min3-May-11 19:23 
QuestionHuffman decoding from using two queues and cursors Pin
Francis Paran3-May-11 5:00
Francis Paran3-May-11 5:00 
Hey everybody,

can anybody help me decode the right characters from their binary codes stored in a file? I have this decoding algorithm that goes through all the bits strings and checks if it's 1 so it can output the value stored at the left child of a node in the Huffman tree. However, I only get 'e' every time it prints out every decoded characters in the binary sequence. To give everyone an idea, here is what the decode looks like:

void decode (QueueNode *ithNode, char *bitCode, int codeLength)
{
     QueueNode *curNode = ithNode;
     
     for (int j = 0; j<codeLength; j++)
     {
         if (bitCode[j] == '1')
         {
            cout<<curNode->leftCursor->value;
            continue;
            }
         else
             curNode = ithNode->rightCursor;
             }
}
//At the main program,

ifstream codeIn("outfile.txt", ios::ate);//outfile contains the binary codes
    char *charGet;
    size = codeIn.tellg();
    codeIn.seekg (0, ios::beg);
    charGet = new char[size];
    for (i = 0; i<size; i++)
        codeIn>>noskipws>>charGet[i];
    
    cout<<"\nDecoding file:\n";
    
    decode(codeTree, charGet, size);

; but then the output looks like this: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eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

At this point, the user needs only to enter any character to exit; the program has no runtime error at all.

Can anyone please help me with this? Thank you.
AnswerRe: Huffman decoding from using two queues and cursors [modified] Pin
Albert Holguin3-May-11 13:51
professionalAlbert Holguin3-May-11 13:51 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Francis Paran3-May-11 14:11
Francis Paran3-May-11 14:11 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Albert Holguin3-May-11 17:03
professionalAlbert Holguin3-May-11 17:03 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Francis Paran4-May-11 2:07
Francis Paran4-May-11 2:07 
AnswerRe: Huffman decoding from using two queues and cursors Pin
Stefan_Lang3-May-11 20:53
Stefan_Lang3-May-11 20:53 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Francis Paran4-May-11 2:03
Francis Paran4-May-11 2:03 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Stefan_Lang4-May-11 2:07
Stefan_Lang4-May-11 2:07 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Francis Paran4-May-11 2:11
Francis Paran4-May-11 2:11 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Stefan_Lang4-May-11 2:33
Stefan_Lang4-May-11 2:33 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Francis Paran4-May-11 3:58
Francis Paran4-May-11 3:58 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Stefan_Lang4-May-11 5:24
Stefan_Lang4-May-11 5:24 
GeneralRe: Huffman decoding from using two queues and cursors [modified] Pin
Francis Paran4-May-11 5:47
Francis Paran4-May-11 5:47 
AnswerRe: Huffman decoding from using two queues and cursors Pin
David Crow4-May-11 2:55
David Crow4-May-11 2:55 
GeneralRe: Huffman decoding from using two queues and cursors Pin
Francis Paran4-May-11 3:50
Francis Paran4-May-11 3:50 
QuestionRe: Huffman decoding from using two queues and cursors Pin
David Crow4-May-11 5:38
David Crow4-May-11 5:38 
AnswerRe: Huffman decoding from using two queues and cursors Pin
Francis Paran4-May-11 5:59
Francis Paran4-May-11 5:59 
GeneralRe: Huffman decoding from using two queues and cursors Pin
David Crow4-May-11 7:10
David Crow4-May-11 7:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.