Monday, January 9, 2012

C program for Decoding an Encoded file

/*program to decode an encoded file and storing decoded data into an another file */

#include<stdio.h>
void main()
{
int d,i;
char c;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("resume_e.txt","r");           //open same encoded file in previous post
fp2=fopen("dec_resume.txt","w");

while((c=fgetc(fp1))!=EOF)      
{
d=c;
d=d-30;                     //here you should use the same value ie., in the previous
c=d;                            //post I used d=d+30 so here i should use d=d-30;
fputc(c,fp2);
puts("processing...");              
}
clrscr();
fclose(fp1);
fclose(fp2);
puts("decoding is over");
getch();
}

 

No comments:

Post a Comment