PDA

View Full Version : Decompression of file data


silverarrow
03-06-2009, 03:50 PM
I have stored some data in a file.txt which is ho3w2 are you.
How can I open this file in c compiler and save the data into a new file (file2.txt) as hoooww are you(replace no. with char)?

file data to read: ho3w2 are you (read from file.txt)
data after decompression: hoooww are you (to be stored in file2.txt)

how can you mkae a code that takes an input file(file.txt) and stores decompressed data(done in the program) in file2.txt??

oracleguy
03-06-2009, 04:11 PM
You would read the compressed file into a buffer in your program and then go through it a character at a time and expand it. What code have you written so far?

RooFi
03-06-2009, 07:07 PM
well .. read the text file untill end of file while storing every character in an array ..say arr .. e.g. "h" comes .. we have arr[i]= received char, h
and then "o" comes ... arr[i] = received char , o
when a digit comes.. say 3 in ur case .. read arr[i-1] and append that char 3-1 =2 times in the array !!