Click here to Skip to main content
15,884,298 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: XML Parsing using Tiny XML Pin
Code-o-mat28-Apr-11 4:10
Code-o-mat28-Apr-11 4:10 
AnswerRe: XML Parsing using Tiny XML Pin
jschell28-Apr-11 8:24
jschell28-Apr-11 8:24 
QuestionGenerating Huffman Coding using Two Queues and a Cursor Pin
Francis Paran28-Apr-11 3:45
Francis Paran28-Apr-11 3:45 
QuestionRe: Generating Huffman Coding using Two Queues and a Cursor Pin
David Crow28-Apr-11 9:04
David Crow28-Apr-11 9:04 
AnswerRe: Generating Huffman Coding using Two Queues and a Cursor Pin
Francis Paran28-Apr-11 12:17
Francis Paran28-Apr-11 12:17 
GeneralRe: Generating Huffman Coding using Two Queues and a Cursor Pin
David Crow29-Apr-11 4:01
David Crow29-Apr-11 4:01 
GeneralRe: Generating Huffman Coding using Two Queues and a Cursor Pin
Francis Paran29-Apr-11 6:25
Francis Paran29-Apr-11 6:25 
GeneralRe: Generating Huffman Coding using Two Queues and a Cursor Pin
David Crow29-Apr-11 8:20
David Crow29-Apr-11 8:20 
I know it's not what you are after, and I may be way off base here, but it seems you are making things a bit more difficult than need be. If you are simply wanting to count letter occurances, something like the following should suffice:

struct node
{
    char c;
    int count;
};
  
int comparater( const void *arg1, const void *arg2 )
{
    node a = *((node *) arg1);
    node b = *((node *) arg2);
  
    return a.count - b.count;
}
  
void main( void )
{
    node frequencies[256] = {0};
  
    // assign 'letters' to each node
    for (int x = 0; x < sizeof(frequencies) / sizeof(node); x++)
        frequencies[x].c = x;

    /*****[ populate frequency array with counts ]*****
    FILE *pFile = fopen("c:\\win.ini", "r");
    if (pFile != NULL)
    {
        while (feof(pFile) == 0)
        {
            int c = fgetc(pFile); // c will be in the -1..255 range
            if (c >= 0)
                frequencies[c].count++;
        }
  
        fclose(pFile);
    }
    */

    qsort(frequencies, sizeof(frequencies) / sizeof(node), sizeof(node), comparater);
  
    std::cout << "The two letters with the highest frequency are " 
              << frequencies[255].c 
              << " and " 
              << frequencies[254].c 
              << std::endl;
}

"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather


GeneralRe: Generating Huffman Coding using Two Queues and a Cursor Pin
Francis Paran29-Apr-11 10:31
Francis Paran29-Apr-11 10:31 
GeneralRe: Generating Huffman Coding using Two Queues and a Cursor Pin
David Crow2-May-11 2:51
David Crow2-May-11 2:51 
QuestionWindows 7 compatible code in VC++ MFC Pin
Janaiko28-Apr-11 3:34
Janaiko28-Apr-11 3:34 
AnswerRe: Windows 7 compatible code in VC++ MFC Pin
Hans Dietrich28-Apr-11 4:10
mentorHans Dietrich28-Apr-11 4:10 
AnswerRe: Windows 7 compatible code in VC++ MFC Pin
Albert Holguin28-Apr-11 8:41
professionalAlbert Holguin28-Apr-11 8:41 
AnswerRe: Windows 7 compatible code in VC++ MFC Pin
Andrew Phillips30-Apr-11 6:16
Andrew Phillips30-Apr-11 6:16 
QuestionIs PnP Device ID unique Pin
champ2328-Apr-11 2:42
champ2328-Apr-11 2:42 
AnswerRe: Is PnP Device ID unique Pin
Hans Dietrich28-Apr-11 4:12
mentorHans Dietrich28-Apr-11 4:12 
QuestionBitmap in List control Pin
Anu_Bala28-Apr-11 0:28
Anu_Bala28-Apr-11 0:28 
QuestionRe: Bitmap in List control Pin
David Crow28-Apr-11 3:16
David Crow28-Apr-11 3:16 
QuestionC++ program and my __asm Pin
francesco.s27-Apr-11 23:51
francesco.s27-Apr-11 23:51 
AnswerRe: C++ program and my __asm Pin
Richard MacCutchan28-Apr-11 1:27
mveRichard MacCutchan28-Apr-11 1:27 
AnswerRe: C++ program and my __asm Pin
Hans Dietrich28-Apr-11 7:12
mentorHans Dietrich28-Apr-11 7:12 
AnswerRe: C++ program and my __asm Pin
Andrew Phillips30-Apr-11 4:49
Andrew Phillips30-Apr-11 4:49 
QuestionHow to use the mysql in the child thread ? Pin
wangningyu27-Apr-11 21:42
wangningyu27-Apr-11 21:42 
AnswerRe: How to use the mysql in the child thread ? Pin
_AnsHUMAN_ 27-Apr-11 23:58
_AnsHUMAN_ 27-Apr-11 23:58 
QuestionHow do i get a InterlockedCompare ? Pin
cl_gamer27-Apr-11 15:52
cl_gamer27-Apr-11 15:52 

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.