I have not tried the code you link to, but it seems to me that you could run into trouble if you run it on an operating system that has differences in handling of text-files and binary files (such as dos, windows, macos and some others...). On POSIX-compliant os'es, there is no such difference. Try to open the files as binary files by adding a "b" to the mode argument of fopen:
Code:
fopen(..., "w") -> fopen(..., "wb")
fopen(..., "r") -> fopen(..., "rb")
fopen(..., "r+") -> fopen(..., "rb+")
good luck,
alex