Wednesday 15 February 2012

C++ program in text files to read and copy only vowel words from one file and put it in to other

C++ program in text files to read and copy only vowel words from one file and put it in to other

#include <fstream.h>
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
void vowelwords()
{
fstream afile,bfile;
char ch,ch1;
afile.open("TEXT1.TXT", ios::in);
bfile.open("TEXT2.TXT", ios::out);
ch1 = ' ';
clrscr();
while(afile)
{
afile.get(ch);
cout << "\nOutside " << ch;
if (( ch =='A') || (ch =='E') || (ch=='I')||(ch=='O')||(ch=='U')&&(ch1==' '))
{
while(ch != ' ')
{
afile.get(ch);
ch1 = ch;
if(ch == ' ')
break;
}
}
else
bfile.put(ch);
}
afile.close();
bfile.close();
}
void main()
{
clrscr();
vowelwords();
}

Step by step explanation:

1.the header file "iostream.h" is used to include the function cin and cout.
2.the header file"conio.h"is used to include the function like getch and clrscr.
3.void vowelwords is also a void type function.
4.while is a conditional statement it is used to check the condition.
5.void main is also a void type function it is worked under the curley brackets.

No comments:

Post a Comment