In my code, I have it to read the file into int c untill EOF (-1). This works perfect for text files, but when I try to read other files (say, mp3 or doc) it stops way short, at around 59 b to 2 kb. What's the problem, and how can I solve it?
In my code, I have it to read the file into int c untill EOF (-1). This works perfect for text files, but when I try to read other files (say, mp3 or doc) it stops way short, at around 59 b to 2 kb. What's the problem, and how can I solve it?
How about posting some code so we can see what your problem is? I can't even imagine what your problem could be. Well actually I could, but it could be millions of little errors that your missing.
Also include OS and compiler, and maybe anything else that might help us help you.
Tyouk
Thats really hard to answer without seeing how you are reading in the data.
With the data files did you open them as binary or normal?
The code is an encrypting program: this is from the encrypt function. It's very easy to understand.Code:while(c != EOF) { c = fgetc(pla); if(c == EOF) { break; } c += key[i]; fputc(c,cip); i++; if(i > strlen(key)) { i = 0; } c = 0; }
Compiler: DMC (Digial Mars C)
OS: Windows (Longhorn build 4051) [I know it's not an OS problem cuz I've tried it on others]
it'd be easier for me to read on byte at a time, instead of a block :/
Ok now let me ask you this.. is a MP3 file a text file? If not why are you treating it as such?
I type in the filename ("ACDC.mp3" or "whatever.doc"), and have the program try to encrypt it. Problem is, the encrypted file is only a few bytes or a couple kb big, which is way to small.
the file is a REAL mp3 file, with real Audio on it, not a text file with a .mp3 extension.
Exactly. Try opening as a binary file and try it.
but, then wouldn't c = 1 or 0? couldn't that screw up the encryption?
Nvm, it works just fine: the mp3 plays find after decryption now.
Thanks again, thantos!
Glad it worked.
Yeah the binary file thing is a little confusing at first
Luckily the functions deal with the hard stuff.