How To Write a C Program To Convert The File Contents In Upper-Case & Write Contents In A Output File in C Programming Language ?
Write a program to read a text file and convert the file contents in capital (Uppercase) and write the contents in a output file. Program to copy the contents of one file into another by changing case.
Solution For C Program To Convert The File Contents In Upper-Case & Write Contents In A Output File:
Tags: C Program To Convert The File Contents In Upper-Case & Write Contents In A Output File, convert lowercase to uppercase in c program, c program to count no of lines, blank lines, comments in a given program, c program to convert lowercase to uppercase and vice versa, convert lowercase to uppercase in c without using function, c program to check uppercase or lowercase, toupper in c, tolower in c, file handling in c.#include<stdio.h> #include<process.h> void main() { FILE *fp1,*fp2; char a; clrscr(); fp1=fopen("test.txt","r"); if(fp1==NULL) { puts("cannot open this file"); exit(1); } fp2=fopen("test1.txt","w"); if(fp2==NULL) { puts("Not able to open this file"); fclose(fp1); exit(1); } do { a=fgetc(fp1); a=toupper(a); fputc(a,fp2); }while(a!=EOF); fcloseall(); getch(); }Explanation :
Open one file in the read mode another file in the write mode.fp1=fopen("test.txt","r"); fp2=fopen("test1.txt","w");Now read file character by character. toupper() function will convert lower case letter to upper case.do { a=fgetc(fp1); a=toupper(a); fputc(a,fp2); }while(a!=EOF);After converting into upper case, we are writing character back to the file. Whenever we find End of file character then we terminate the process of reading the file and writing the file.
Learn More :
C Program
- Using Bash to input stuff into c program
- Difficult C Programming Questions
- Write a c program to find largest among three numbers using binary minus operator three numbers using binary minus operator
- PRINTING ASCII VALUE USING C PROGRAM
- MULTIPLICATION OF TWO MATRICES USING C PROGRAM
- FIND OUT SUM OF DIAGONAL ELEMENTS OF A MATRIX USING
- Write A C Program To Find Out Transport Of A Matrix
- Factorial of 100 in C Program
- Multiplication of large numbers in c
- Division of Large Numbers in C Program
- BINARY SEARCH USING C PROGRAM
- BINARY SEARCH THROUGH RECURSION USING C PROGRAM
- FIND FACTORIAL OF A NUMBER USING RECURSION IN C PROGRAM
- FIND GCD OF A NUMBER USING RECURSION IN C PROGRAM
- FIND SUM OF DIGITS OF A NUMBER USING RECURSION USING C PROGRAM
- FIND POWER OF A NUMBER USING RECURSION USING C PROGRAM
- REVERSE A NUMBER USING RECURSION IN C PROGRAM
- SWAP TWO VARIABLES WITHOUT USING THIRD USING C PROGRAM VARIABLE
- Write A C Program For Swapping Of Two Arrays
- SWAPPING OF STRINGS USING C PROGRAM
- CONVERSION FROM DECIMAL TO OCTAL USING C PROGRAM
- CONVERSION FROM DECIMAL TO OCTAL USING C PROGRAM
- CONVERSION OF DECIMAL TO BINARY USING C PROGRAM
- CONVERSION OF FAHRENHEIT TO CENTIGRADE USING C PROGRAM
- C or C++ Program To Find Bonus Amount