title: C++ Huffman Code Header
body: <p>basically, I've got my Huffman table as </p>
  
  <pre><code>std::map&lt;std::string, char&gt; ciMap;
  </code></pre>
  
  <p>Where string is the bit pattern and char is the value represented by said pattern.
  The problem is how do I store that as a header of my compressed file so I can build again the same map when I want to decode it?</p>
  
  <p>Trying to store it as binary:</p>
  
  <pre><code>size_t mapLen = ciMap.size();
  outFile.write(reinterpret_cast&lt;char*&gt;(&amp;mapLen), sizeof(size_t));
  outFile.write(reinterpret_cast&lt;char*&gt;(&amp;ciMap), sizeof(ciMap));
  </code></pre>
  
  <p>And later building with:</p>
  
  <pre><code>inFile.read(reinterpret_cast&lt;char*&gt;(&amp;mapLen), sizeof(size_t));
  inFile.read(reinterpret_cast&lt;char*&gt;(&amp;ciMap), sizeof(mapLen));
  </code></pre>
  
  <p>Doesn't work, I get string initilization error... something to do with NULL. Any suggestions? If you have better way of storing the bits and values I'd like to hear.</p>