#include #include #include #include void main() { FILE *f1; FILE *f2; FILE *f3; char ch,nc; int i,j,k,key,key2; clrscr(); f1=fopen("pt.txt","r"); f2=fopen("ct.txt","w"); if(f1==NULL) { printf("Can't open one of the files. Exiting ..."); exit(1); } printf("Enter the key: "); scanf("%d",&key); while(1) { ch=fgetc(f1); if(ch==EOF) break; nc=ch; if(isupper(ch)) { nc =key; if(nc>90) nc-=26; } if(islower(ch)) { nc =key; if(nc>122) nc-=26; } fputc(nc,f2); } fclose(f1); fclose(f2); printf("\n\nDecryping now ,,, \n\n"); f2=fopen("ct.txt","r"); f3=fopen("dt.txt","w "); ch='a'; while(1) { ch=fgetc(f2); if(ch==EOF) break; nc=ch; if(isupper(ch)) { nc-=key; if(nc<65) nc =26; } if(islower(ch)) { nc-=key; if(nc<97) nc =26; } fputc(nc,f3); } printf("\nEnd of Program. Press any key to exit."); getch(); }