title: Huffman,Stack overflow
body: <pre><code>void decodeFile(ibstream&amp; infile, Node* encodingTree, ostream&amp; file) {
      // initializing map here.
  
      string code = "";
      /*while (true) {
          code += integerToString(infile.readBit());        
          if (map.containsKey(code)) {
              if (map[code] == PSEUDO_EOF) break;
              file.put(map[code]);
              code = "";
          }
      }*/
      bitToString(infile,file,code,map);
  }
  </code></pre>
  
  <p>given method with commented part works fine, I'm tring to do recursion instead of while cycle. </p>
  
  <pre><code>void bitToString(ibstream&amp; infile, ostream&amp; file,string&amp; code,Map&lt;string,ext_char&gt;&amp; map){      
      code += integerToString(infile.readBit());
      if (map.containsKey(code)) {
          if (map[code] == PSEUDO_EOF) return;
          file.put(map[code]);
          code="";
      }
      bitToString(infile,file,code,map);
  }
  </code></pre>
  
  <p>but, with this recursion it gives stack owerflow error on big files.</p>
  
  <blockquote>
    <p>Unhandled exception at 0x621dffde in Huffman Encoding.exe: 0xC00000FD:
    Stack overflow.</p>
  </blockquote>