/  C Programs   /  Program to change letters case in a file

Program to change letters case in a file

Program to change all upper-case letters in a file to lower case letters and vice versa.

 

#include<stdio.h>
main()
{
FILE *fp1,*fp2;
char c;
fp1=fopen("text.txt","r");
fp2=fopen("copy.txt","w");
while((c=getc(fp1))!=EOF)
{
if(c>=65&&c<=91)
c=c+32;
else
c=c-32;
putc(c,fp2);
}
fcloseall();
}

 

Program to change letters case in a file

 

Output:

 

Program to change letters case in a file

 

Leave a comment