Hello,writing codes here
Qt Code:
  1. //Writing size of map
  2. uint16_t streamOffset = (sizeof(int)+sizeof(char))*FrekMap.size()+sizeof(uint16_t);
  3. codefile.write(reinterpret_cast<char*>(&streamOffset),sizeof(uint16_t));
  4. //Writing map
  5. for (QMap<char,int>::Iterator it = FrekMap.begin(); it != FrekMap.end(); ++it) {
  6. codefile.putChar(it.key());
  7. codefile.write(reinterpret_cast<char*>(&(it.value())), sizeof(int));
  8. }
  9. //Writing lenght last byte
  10. codefile.putChar(compressed.length()%8);
  11. while(compressed.length()%8!=0)
  12. compressed.push_back('0');
  13. //Writing code
  14. compressedData=compressed.constData();
  15. for(int i = 0; i < compressed.size(); i++ )
  16. {
  17. if( compressedData[i] == ZeroBit )
  18. k++;
  19. else if( compressedData[i] == OneBit )
  20. {
  21. buff |= bits[k];
  22. k++;
  23. }
  24. if( k == 8 )
  25. {
  26. codefile.write(reinterpret_cast<char *>(&buff),sizeof(unsigned char));
  27. buff = 0;
  28. k = 0;
  29. }
  30. }
To copy to clipboard, switch view to plain text mode 
Reading codes here
Qt Code:
  1. //read size of map
  2. readData.read(reinterpret_cast<char*>(&sizeMap),sizeof(sizeMap));
  3. //read map
  4. for (int i=sizeof(uint16_t);i<sizeMap;i+=sizeof(int)+sizeof(char)) {
  5. char charofmap;
  6. int freq;
  7. readData.getChar(reinterpret_cast<char*>(&charofmap));
  8. readData.read(reinterpret_cast<char*>(&freq), sizeof(int));
  9. FreqTable.insert(charofmap,freq);
  10. }
  11. //read last byte lenght
  12. readData.getChar(reinterpret_cast<char*>(&lengthLast));
  13. //read code to bit
  14. while (!readData.atEnd()) {
  15. unsigned char ch;
  16. readData.getChar(reinterpret_cast<char*>(&ch));
  17. codeLetter+=unschartoQString(ch);
  18. }
To copy to clipboard, switch view to plain text mode 

I can't read true for writing code.Where is my problem?