title: How to read huffman tree frequency from a file
body: <p>I have to create a huffman tree whose alphabtes(symbols, i mean "aaabbacaccba" etc.) must be given as Input.txt file at sole argument.</p>
  
  <p>I then have to create the frequency corresponding to each  alphabtes.
  I have problem in createing frequencies.
  I want something like this: suppose if i have to read this in input.txt: <code>"aabcccadde"</code>. Then my code must print like this:</p>
  
  <pre><code>sym:a, freq:3
  sym:b, freq:1
  sym:c, freq:3
  sym:d, freq:2
  sym:e, freq:1
  </code></pre>
  
  <p>My code for this is working correctly: see below:</p>
  
  <pre><code>   while (c != EOF &amp;&amp; c != '\n' &amp;&amp; c != '\r') 
     {
      Object1.data[count].symbol = c;
      if(Object1.data[count].symbol =='a')
      {
        save_a++;
      }
      if(Object1.data[count].symbol =='b')
      {
        save_b++;
      }
      if(Object1.data[count].symbol =='c')
      {
        save_c++;
      }
      if(Object1.data[count].symbol =='d')
      {
        save_d++;
      }
      if(Object1.data[count].symbol =='e')
      {
        save_e++;
      }
      count++;
      c = fgetc(input_file);
     }
      cout&lt;&lt; "save_a : "&lt;&lt;save_a &lt;&lt;endl&lt;&lt; "save_b : "&lt;&lt;save_b &lt;&lt;endl&lt;&lt; "save_c: "&lt;&lt;save_c&lt;&lt;endl&lt;&lt; "save_d : "&lt;&lt;save_d &lt;&lt;endl&lt;&lt; "save_e: "&lt;&lt;save_e&lt;&lt;endl;
  </code></pre>
  
  <p>so the output is:</p>
  
  <pre><code>save_a : 5
  save_b : 3
  save_c: 2
  save_d : 2
  save_e: 3  
  </code></pre>
  
  <p>But the problem is when user again changes the frequency to "pqabbaddqpc". The user here added two more alphabets, where i have only counter to read the count of a,b,c,d and e only. I mean i want to create some dynamic kind of system where the user can enter any alphabets to calculate the frequencies.</p>
  
  <p>Is it possible to do achieve this ?<br>
  Any help please ?</p>