Ive wrote a very simple pogram that encrypts a .txt file by reading every char in it , promoting it by 1, and then putting the result in a new .txt file .
then the prog reads the "encrypted "file and decrypts it by substructing 1 from every char.
for example if those chars apear in the file :
after running the program it creats 2 files :
encrypted.txt:
and decrypted.txt
BUT when i run the program on a file with those chars:
Code:
Edֳ$x7ֳ$x7ֳ$x7987ֶ$x7d7ָ$x7ֳ$x7ֲ$x7ֳ$y7D$x79a7־$x7T=7ֲ$x7e7$x79E7ֲ$x7Richֳ$x7 PE L „}; א ( ”
the result is :
encrypted.txt:
Code:
Feִ%y8ִ%y8ִ%y8:98ַ%y8e8ֹ%y8ִ%y8ֳ%y8ִ%z8E%y8:b8ֿ%y8U>8ֳ%y8f8א%y8:F8ֳ%y8Sjdiִ%y8!!!!!!!!!!!!!!!!!!!!!!!!QF!!M!…~<!!!!!!!!ב!!!)!!•!
decrypted.txt:
Code:
Edֳ$x7ֳ$x7ֳ$x7987ֶ$x7
this is the code:
Code:
while(ch!=EOF){ /*encryption*/
ch=fgetc(src); /* ch,chr are int */
chr=ch+1;
fputc(chr,dst);
}
Code:
while(ch2!=EOF){ /*decryption*/
ch2=fgetc(src); /* ch2,chr2 are int */
chr2=ch2 -1;
fputc(chr2,dst);
}
I think the problem is that for some reason when the chars " "appear the compiler thinks one of them is an EOF and stops.
can that be the problem or is it something else?
plz hlp me fix this BUG!