Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- void main()
- FILE*fp ;
- FILE*fp1 ;
- FILE*r;
- int n;
- int i,j,k,l;
- char a[100],c[100],d[100],h[100];
- char buf[100];
- char *p;
- fp=fopen("encrypted.txt","a");
- fp1=fopen("decrypted.txt","a");
- r=fopen("search.txt","a");
- printf("\nEnter Plain Text : ");
- gets(a);
- l=strlen(a);
- for(i=0,j=0;i<l;i++)
- {
- if(i%2==0)
- c[j++]=a[i];
- }
- for(i=0;i<l;i++)
- {
- if(i%2==1)
- c[j++]=a[i];
- }
- c[j]='\0';
- printf("\n encrypted text : ",c);
- printf("\n %s",c);
- fprintf(fp," encrpyted text : %s \n ",c);
- if(l%2==0)
- k=l/2;
- else
- k=(l/2)+1;
- for(i=0,j=0;i<k;i++)
- {
- d[j]=c[i];
- j=j+2;
- }
- for(i=k,j=1;i<l;i++)
- {
- d[j]=c[i];
- j=j+2;
- }
- d[l]='\0';
- printf("\n decrypted text : ");
- printf(" \n %s",d);
- fprintf(fp1," decrypted text : %s \n",d);
- fprintf(r," decrpyted text: %s\n" ,d);
- fclose(fp);
- fclose(fp1);
- fclose(r);
- r=fopen("search.txt","r");
- printf("\n \n \n ");
- printf("search text:");
- gets(h);
- while(fgets(buf,100,r))
- {
- p=strstr(buf,h);
- if(p!=NULL){
- printf( " \n word found: %s",p);
- n=1;
- }
- }
- if (n!=1){
- printf("word not found");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement