title: Huffman Coding: storing bytes and it's frequency reading it from a file, in C
body: <p>I have to store bytes (256 possibilities) and its frequency, reading it from a file and storing it in a struct array.</p>
  
  <p>It has to read simple files like txt, png, mp3 and pdf.I know the Huffman Coding theory, but Im having problems to get the frequency table. I would appreciate tips in C language.</p>
  
  <p>Ex.:  After reading a file, I get three bytes: 0000 1111, 1111 0000, 1111 0000</p>
  
  <pre><code>Bytes        Frequency
  0000 1111       1
  1111 0000       2
  </code></pre>
  
  <p>Here is what I got so far:</p>
  
  <pre><code>#define NUM_BYTES 256
  
  typedef struct Node{
      unsigned int frequency;
      char* symbol;
  } Node;
  
  GetByteFrequency( char* fileName, Node* table){
      FILE* filep = fopen( fileName, "r" );
      fread(&amp;table, 1, sizeof(char), filep);
      fclose(filep);
  }
  
  int main(){
      Node frequencyTable[NUM_BYTES-1];
      GetByteFrequency("text.txt", frequencyTable);
      return 0;
  }
  </code></pre>
  
  <p>This code is not working how it has to, its just to give an idea of Im doing.</p>