I want to write simple encrypt text system that is read from in.txt then write to out.txt Encryption type is every ascii plus five if char btw u and z , u=a,v=b,......,z=f where is my problem? Besides, can we do using modulos operator(%) instead of (char-20) if char btw u and z , u=a,v=b,......,z=f where is my problem? my code is below thank you all appreciated answers. text is in in.txt that test abcde
#include <stdio.h>
int main(){
char ch;
int st;
FILE *fptr_in;
FILE *fptr_out;
fptr_in=fopen("in.txt","r");
fptr_out=fopen("out.txt","w");
if(fptr_in== NULL || fptr_out==NULL)
printf("File cannot be opened\n");
else{
st=(fscanf(fptr_in,"%c",&ch));
while(st==1){
/* for(st=(fscanf(fptr_in,"%c",&ch));
st==1;
st=(fscanf(fptr_in,"%c",&ch)))*/
st=(fscanf(fptr_in,"%c",&ch));
if('a'<=ch && ch<='z'){
fscanf(fptr_in,"%c",&ch);
if(ch==' ')
fprintf(fptr_out, "%c", ' ');
else if('u'<=ch && ch<='z')
fprintf(fptr_out, "%c", (char)((int)ch-20));
else
fprintf(fptr_out, "%c", (char)((int)ch+5));
}
}
}
fclose(fptr_in);
fclose(fptr_out);
return 0;
}