#include<fstream.h>
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
char file[50],a[50],b;
void write()
{
ofstream file1;
file1.open(file,ios::out);
cout<<"\nEnter data to be entered in the file: ";
gets(a);
file1<<a;
file1.close();
}
void uppercase()
{
ofstream file1;
file1.open(file,ios::out) ;
while(file1.get(a))
cout<<toupper(a);
cout<<endl;
file1.close();
}
void read()
{
ifstream file1;
file1.open(file,ios::in);
cout<<"\nContent of this file: ";
while(file1.get(b))
cout<<b;
cout<<endl;
file1.close();
}
void main()
{
int ch;
clrscr();
cout<<"Enter file name: ";
cin>>file;
cout<<endl;
do
{
cout<<"1. Change File name."<<endl;
cout<<"2. Write on the file."<<endl;
cout<<"3. Change contents of the file to uppercase."<<endl;
cout<<"4. Read the file."<<endl;
cout<<"5. Exit."<<endl;
cout<<"Enter your choice: ";
cin>>ch;
switch(ch)
{
case 1: {
cout<<"\nEnter File name: ";
cin>>file;
cout<<endl;
break;
}
case 2: {
write();
break;
}
case 3: {
uppercase();
break;
}
case 4: {
read();
break;
}
case 5: {
break;
}
default: {
cout<<"\nWrong choice entered.\n"<<endl;
break;
}
}
cout<<endl;
}
while(ch!=5);
}