Sie sind auf Seite 1von 2

#include <iostream.

h>
#include <string.h>
#include <fstream.h>
#include <stdio.h>
#include <ctype.h>
#include<conio.h>
char q[500];
void writetxt();
void readtxt();
int main()
{
clrscr();
writetxt();
readtxt();
getch();
return 0;
}
void writetxt()
{

fstream infile;
infile.open("essay.txt",ios::in|ios::out);
cout<<"Enter the string";
gets(q);
infile<<q;
infile.close();
}
void readtxt()
{
char curLetter;
int j, len, vA, vE, vI, vO, vU, vY, totV;
vA=0, vE=0, vI=0, vO=0, vU=0, vY=0, totV=0;
len=strlen(q);
ifstream fin("essay.t");
if (!fin)
cout << "NO INPUT FILE!!!" << endl;
while (fin.getline(q,'\n'))

{
for(j=0;j<len;j++)
{
curLetter = (toupper(q[j]));
if (curLetter == 'A')
{
vA++;
totV++;
}
else if (curLetter == 'E')
{
vE++;
totV++;
}
else if (curLetter == 'I')
{
vI++;
totV++;
}
else if (curLetter == 'O')
{
vO++;
totV++;
}
else if (curLetter == 'U')
{
vU++;
totV++;
}
}
}
cout
cout
cout
cout
cout
cout

<<
<<
<<
<<
<<
<<

"Total Vowels: "


"\nTotal A: " <<
"\nTotal E: " <<
"\nTotal I: " <<
"\nTotal O: " <<
"\nTotal U: " <<

<< totV;
vA;
vE;
vI;
vO;
vU<<endl;

Das könnte Ihnen auch gefallen