In this program user asks to convert all characters that are contained in a file to uppercase. To make this process user need to make a file and fill up some characters in it for operation. User declares the variables. And then put up a function to open file and also fill up character in it. Then if condition checks whether the file exists or not if the condition goes true then the program will terminate because file does not exist or then after while condition checks out the file and character and put up the condition to convert it into uppercase. Display the result on the screen.
Problem Statement:
This is c program that asks user to converts all the character in file into Upper case.
- Declaring variable.
- Using control statement.
- Put in while condition.
- Display the result on the screen.
Here is C source code for Converting the Character into Uppercase. The output of this program shown below.
#include<stdio.h>
#include<ctype.h>
void main()
{
FILE*f1;
char ch,fname[20],d;
clrscr();
f1=fopen(fname,"w");
printf("\nEnter File Name :");
scanf("%s",& fname);
f1=fopen(fname,"r");
if(f1==NULL)
{
printf("File can't be Opened");
exit();
}
while(ch!=EOF)
{
d=toupper(ch);
printf("%c",d);
ch=fgetc(f1);
}
fclose(f1);
getch();
}