Text2 (Convert To Upper)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

#include<fstream.

h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
fstream f1,f2;
char s[101],ch;
void main()
{
clrscr();
f1.open("File.txt",ios::out);
do
{
cout<<"Enter a line(Max 100 characters):";
gets(s);
f1<<s<<'\n';
cout<<"\nDo you want to enter more(y/n)?:";
cin>>ch;
}while(ch=='y'||ch=='Y');
f1.close();
f1.open("File.txt",ios::in);
f2.open("New.txt",ios::out);
while(!f1.eof())
{
f1.get(ch);
ch=(char)toupper(ch);
f2<<ch;
}
f1.close();
f2.close();
cout<<"\nThe Contents of the new file are-\n";
f2.open("New.txt",ios::in);
while(!f2.eof())
{
f2.get(ch);
cout<<ch;
}
f2.close();
getch();
}
//OUTPUT
Enter a line(Max 100 characters):naman bagga is my name and my Age is 17
Do you want to enter more(y/n)?:y
Enter a line(Max 100 characters):This is a text File
Do you want to enter more(y/n)?:n
The Contents of the new file areNAMAN BAGGA IS MY NAME AND MY AGE IS 17
THIS IS A TEXT FILE

You might also like