Thread: writting back to files using char(bits) to save memory

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    118

    writting back to files using char(bits) to save memory

    HI i am trying to write back a compressed string (compression was done using huffman encoding) back to a file.I am using an unsigned char as a buffer and getting each character in my string,getting its encoded value and setting my bits to the encoded value.If my buffer is full i flush it.The problem is i have writen my code and it does not work.My text editor wont even recognise the file that is written to.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, the file is compressed, so it isn't likely you will be able to make sense if you can open it.
    You need to expand upon "does not work," however and show some code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    118
    Quote Originally Posted by Elysia View Post
    Well, the file is compressed, so it isn't likely you will be able to make sense if you can open it.
    You need to expand upon "does not work," however and show some code.
    yes you are right.would you by any chance tell me how i can decompress my string from the file

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    That depends entirely on how you compressed it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    118
    Quote Originally Posted by Elysia View Post
    That depends entirely on how you compressed it.
    i compressed it using an int buffer.Basically for e.g assuming the character is a and its encoding is 111000..i set the int buffer to the individual bits

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Our own tutorial goes into decompressing huffman encoding. My advice: Read it and come back with a more specific question.

    Huffman Encoding Compression Algorithm Tutorial - Cprogramming.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. writting to files
    By sigur47 in forum C++ Programming
    Replies: 1
    Last Post: 02-19-2012, 08:37 AM
  2. Writting hex value into files
    By dhuan in forum C++ Programming
    Replies: 15
    Last Post: 11-03-2010, 11:47 PM
  3. Problem reading/writting binary files.
    By pajaro in forum C Programming
    Replies: 2
    Last Post: 09-05-2009, 12:25 PM
  4. how can i modify the bits of a char?
    By dudeomanodude in forum C++ Programming
    Replies: 14
    Last Post: 02-03-2008, 11:36 AM
  5. Save and Load memory data to Files in C++ ?
    By IndioDoido in forum C++ Programming
    Replies: 18
    Last Post: 10-18-2007, 07:22 PM