All pastes #1315486 Raw Edit

Miscellany

public c v1 · immutable
#1315486 ·published 2009-01-22 05:24 UTC
rendered paste body
#include<stdio.h>#include<conio.h>#include<string.h>#include<ctype.h>void main(){	FILE *f1;	FILE *f2;	FILE *f3;	char ch,nc;	int i,j,k,key,key2;	clrscr();	f1=fopen("pt.txt","r");	f2=fopen("ct.txt","w");	if(f1==NULL)	{		printf("Can't open one of the files. Exiting ...");		exit(1);	}	printf("Enter the key: ");	scanf("%d",&key);	while(1)	{		ch=fgetc(f1);		if(ch==EOF)			break;		nc=ch;		if(isupper(ch))		{			nc =key;			if(nc>90)				nc-=26;		}		if(islower(ch))		{			nc =key;			if(nc>122)				nc-=26;		}		fputc(nc,f2);	}	fclose(f1);	fclose(f2);	printf("\n\nDecryping now ,,, \n\n");	f2=fopen("ct.txt","r");	f3=fopen("dt.txt","w ");	ch='a';	while(1)	{		ch=fgetc(f2);		if(ch==EOF)			break;		nc=ch;		if(isupper(ch))		{			nc-=key;			if(nc<65)				nc =26;		}		if(islower(ch))		{			nc-=key;			if(nc<97)				nc =26;		}		fputc(nc,f3);	}	printf("\nEnd of Program. Press any key to exit.");	getch();}