I have an assignment for coding a Huffman algorithm. I have the whole problem organized in my head, but I'm having some trouble with file handling.
The problem is: the algorithm is supposed to compress ANY kind of file.
My solution: read the file as a byte array, then with an int array[256]={0}
for each byte, get it's int n
corresponding value and increment the array[n]
. If I didn't make it clear, let me know.
So, I've done lots of researching, but don't understand how to get bytes from ANY kind of file and how to handle them.
How about trying binary file IO:
Or something along the lines!!
Now you have an array of bytes containing the file's contents.