Вы находитесь на странице: 1из 1

#include<fstream.

h>
#include<conio.h>
#include<stdio.h>
fstream f1,f2;
char ch,s[101];
void main()
{
clrscr();
f1.open("text1.txt",ios::out);
do
{
cout<<"Enter a line(Max 100 characters):";
gets(s);
f1<<s<<'\n';
cout<<"\nDo you wish to continue?(y/n):";
cin>>ch;
}while(ch=='y'||ch=='Y');
f1.close();
f1.open("text1.txt",ios::in);
f2.open("text2.txt",ios::out);
while(!f1.eof())
{
f1.getline(s,101,' ');
switch(s[0])
{
case 'a': case 'A': case 'e': case 'E': case 'i':
case 'I': case 'o': case 'O': case 'u': case 'U':break;
default:
f2<<s;
}
}
f1.close();
f2.close();
f2.open("text2.txt",ios::in);
cout<<"\nThe contents of the new file-\n";
while(!f2.eof())
{f2.getline(s,101);
cout<<s;
}
f2.close();
getch();
}
//OUTPUT
Enter a line(Max 100 characters):My name is Naman Bagga

Do you wish to continue?(y/n):y


Enter a line(Max 100 characters):http://www.namanb.com is my blog URL

Do you wish to continue?(y/n):n

The contents of the new file-


My name Naman Bagga
http://www.namanb.com my blog

Вам также может понравиться