C Program to Convert the File Contents in Upper-case & Write Contents in a Output File.
⦁ The C library function int toupper(int c) converts lowercase letter to uppercase.
⦁ The declaration for toupper( ) function is as follows:
int toupper(int c );
⦁ c - This is the letter to be converted to uppercase.
⦁ This function returns uppercase equivalent to c, if such value exists, else c remains unchanged. The value is returned as an int value that can be implicitly casted to char.
--------------------------------------------------------------------------------------------------------------------------
#include<stdio.h>
#include<process.h>
void main( )
{
FILE *fp1,*fp2;
char a;
clrscr( );
fp1 = fopen("program1.txt","r");
if(fp1 == NULL){
puts("cannot open this file");
exit(1);
}
fp2 = fopen("program2.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( );
}
--------------------------------------------------------------------------------------------------------------------------
EmoticonEmoticon