Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program that reads the encoded alphabetic text from a file and produces decoded file by replacing each character with the character that occurs five

Posted By: Nicole Hughes     Category: C Programming     Views: 5238

Write a program that reads the encoded alphabetic text
from a file and produces decoded file by replacing each
character with the character that occurs five positions
later in the alphabet A..Z. Character blank should be
replaced with blank itself. Assume that the text consists of only A...Z and blank characters. The replacement should "wrap around" the end of the character set A ..Z so that there is a well-defined replacement for each alphabet.Read text and print its decoded form until a character is found.

Code for Program that reads the encoded alphabetic text from a file and produces decoded file by replacing each character with the character that occurs five in C Programming

#include<stdio.h>
#include<conio.h>

FILE * fin,*fout;
void main()
{
   void input(void);
   void output(void);
   input();
   output();
getch();
}

void input(void)
{
    char c;
    fin=fopen("input12.txt","w");
    printf("\n ENTER THE THE FOR DECODING::");
    while((c=getchar())!=':')
    {
    fprintf(fin,"%c",c);
    }
   fprintf(fin,"%c",c);
   fclose(fin);

}

void output(void)
{
   char c;
   int intc;
   fin=fopen("input12.txt","r");
   fout=fopen("output12.txt","w");
   fprintf(fout,"\n THE DECODED TEXT IS::");
   while((c=getc(fin))!=':')
   {
     // printf("%c",c);if(c!=' ')
      {
     intc=c;
     if(intc+5>122)
     {
        c=96+((intc+5)%122);
     }
     elseif((intc+5>90 && intc+5<96) && intc<97)
     {
        c=64+((intc+5)%90);
     }
     else
       c=intc+5;
      }
       putc(c,fout);
         printf("%c",c);
   }
   fclose(fin);
   fclose(fout);
}


****************************INPUT******************************

abcd wxyz ABCD WXYZ:


****************************OUTPUT******************************

THE DECODED TEXT IS::fghi bcde FGHI BCDE
  
Share: 



Nicole Hughes
Nicole Hughes author of Program that reads the encoded alphabetic text from a file and produces decoded file by replacing each character with the character that occurs five is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!