Program to copy contents of file a.txt to b.txt by changing the case of each alphabet.


C File =>


/* Write a program to copy contents of file a.txt to b.txt by changing the case of each alphabet. */


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


int main()
{
     FILE *fp1,*fp2;
     char ch;
     fp1=fopen("a.txt","r");
     fp2=fopen("b.txt","w");
     if(!fp1)
        printf("\n Error in reading..");
     if(!fp2)
        printf("\n Error in writing..");
     else
     {
          while((ch=fgetc(fp1))!=EOF)
          {
             if(isupper(ch))
                 fputc(tolower(ch),fp2);
             else
                 fputc(toupper(ch),fp2);
           }
      }
return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.