BitShift Entire File

I am trying to convert a 128GB human-readable hexadecimal file in to base 256 binary and then shifting all the bits left by 7.

So far, I have this: http://pastebin.com/raw/giMbciwr
But, it only works for small files but it failed when I tried it on the 128GB file: it kept on adding data to the output file past 64GB.

So, what is wrong with the program I pasted on pastebin, and any suggestions for performance?

Thank you for your replies.
Last edited on
closed account (48bpfSEw)
operating with fgetc is a performance killer!

why don't you read 100KB in a buffer, shift the bytes and write it out?
Thank you so much for your reply. You are incredibly helpful. I will try to update my code.
Topic archived. No new replies allowed.