I'm writing a simple program that reads a text file and counts the vowels in it and outputs how many are included.
With the code I have I keep getting the wrong number of vowels outputted. Can anyone see where I made a mistake, I can't figure it out.
my example file has : aeiou AEIOU
but when the program runs it says there's 11 vowels isntead of 10.
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
using namespace std;
int main()
{
char ValueRead;
int counter=0;
//get name of input file
cout << "Enter the name of the input file: ";
string FileName;
getline(cin, FileName);
//check for success of the input file
ifstream fin;
fin.open(FileName.data());
assert (fin.is_open());
//while not end of file, read in chars and check if theyre a vowel,
//increment counter
while (!fin.eof())
{
fin >> ValueRead;
if (ValueRead = 'A' || 'a' || 'E' || 'e' || 'I' || 'i' || 'O' ||
'o'|| 'U' || 'u')
{
counter++;
}
}
cout << "There are: " << counter << " vowels in the file!"<< endl;
fin.close();
return 0;
}