Friday, October 28, 2011

Encryption {File Writing}

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char a[100],b[100];
    int l,i,j=0;
    char ch;
    FILE *fp;
    clrscr();
    fp=fopen("Encrypt.txt","w");
    printf("\nEnter The String To Be Encrypted:");
    gets(a);
    l=strlen(a);
    if(fp==NULL)
    {
        printf("\nNot Enough Memory");
        getch();
        exit(0);
    }
    for(i=0;i<l;i++)
    {
          ch=a[i];
          for(j=0;j<l;j++)
          ch++;
          b[i]=ch;

    }
    printf("\nAfter Encrypting The String is:");
    puts(b);
    fprintf(fp,"%s",b);
    fclose(fp);
    printf("\nData Has Been Succesfully Written in Encrypt.txt");
    getch();
}

No comments:

Post a Comment