Friday, October 28, 2011

Decryption {File Reading}

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char a[100],b[100];
    int l,i,j;
    char ch;
    FILE *fp;
    fp=fopen("Encrypt.txt","r");
    clrscr();
    if(fp==NULL)
    {
        printf("\nFile Cannot Be Found");
        getch();
        exit(0);
    }
    fscanf(fp,"%s",a);
    printf("\nEncrypted String is:");
    puts(a);
    l=strlen(a);
    for(i=0;i<l;i++)
    {
        ch=a[i];
        for(j=0;j<l;j++)
        ch--;
        b[i]=ch;
    }
    puts("\nThe Decrypted String is:");
    puts(b);
    fclose(fp);
    if(remove("Encrypt.txt")==-1)
    perror("\nError in Deleating a file");
    getch();
}

No comments:

Post a Comment