C File Handling Program to Decrypt the Encrypted File

Hello friends! In this tutorial, I’m going to teach “C File Handling Program to Decrypt the Encrypted File” to you. Shall I start the tutorial to teach the possibilities below? Let’s go.

C File Handling Program to Decrypt the Encrypted File

C File Handling Program to Decrypt the Encrypted File

Program Code

#include <stdio.h>
#include <stdlib.h>

void main()
{
	char ch, fname[20];
	FILE *fpts, *fptt;
	
	printf("nn Decrypt a text file :n");
	printf("--------------------------n"); 	
	
	printf(" Input the name of file to decrypt : ");
	scanf("%s",fname);	
	
	fpts=fopen(fname, "w");
	if(fpts==NULL)
	{
		printf(" File does not exists or error in opening..!!");
		exit(7);
	}
	fptt=fopen("temp.txt", "r");
	if(fptt==NULL)
	{
		printf(" File does not exists or error in opening..!!");
		fclose(fpts);
		exit(9);
	}
	while(1)
	{
		ch=fgetc(fptt);
		if(ch==EOF)
		{
			break;
		}
		else
		{
			ch=ch-100;
			fputc(ch, fpts);
		}
	}
	printf(" The file %s decrypted successfully..!!nn",fname);
	fclose(fpts);
	fclose(fptt);
}

Final Words

I hope this article helps you to clarify about “C File Handling Program to Decrypt the Encrypted File“. If you face any issues please let me know via the comment section. Share this article with other C/C++ developers via social networks. Thank You!

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment