/* program for encoding the text and storing the original and encoded data in files */
#include<stdio.h>
#include<string.h>
void main()
{
char c, data[100], enc[100],enc_bin[8];
int d,i,j;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("original.txt","w");
fp2=fopen("encoded.txt","w");
printf("enter text and press enter --\n\n\t");
i=0;
j=0;
while((c=getchar())!='\n') //main logic
{
data[i++]=c;
fputc(c,fp1); //storing the original data in file
d=c; //converting char to int (ascii value)
d=d+26; // changing its ASCII value by adding 26
c=d; // converting back it to char type
fputc(c,fp2); //putting the encoded text into anotherfile
enc[j++]=c;
}
printf("encoded data is--\n\n\t ");
for(i=0;i<j;i++)
printf("%c",enc[i]);
fclose(fp1);
fclose(fp2);
getch();
}
No comments:
Post a Comment