Monday, January 9, 2012

Encoding an Text file using C program

/* program to encode an text file */

#include<stdio.h>
#include<string.h>

void main()
{
int d,i;
char c;
FILE *fp1,*fp2;
fp1=fopen("resume.txt","r");         //here i used my resume file, you can use any file but it
fp2=fopen("resume_e.txt","w");  // should be in the BIN folder

while((c=fgetc(fp1))!=EOF)      //main logic
{
d=c;
d=d+30;
c=d;
fputc(c,fp2);
puts("processing...");                 //check by keeping this line before the loop
}
clrscr();
fclose(fp1);
fclose(fp2);
printf("text is encoded and stored in file");
getch();
}

No comments:

Post a Comment