Question: I have a program that I need to write about reading from a file in (C++) I have the file already downloaded and I wrote
I have a program that I need to write about reading from a file in (C++)
I have the file already downloaded and I wrote the following:
int main()
{ ifstream inFile;
inFile.open("a05part1.txt");
if (!inFile) { cout << "File did not open! Program terminating!! "; exit (0); }
int vowel = 0; char letter; while (!inFile.eof()); { inFile.get(letter);
if (letter == 'a' || letter == 'A' || letter == 'e' || letter == 'E' || letter == 'i' || letter == 'I' || letter == 'o' || letter == 'O' || letter == 'u' || letter == 'U') { vowel += letter; cout << letter; }
else { cout << letter; } }
inFile.close(); return 0; }
but it keeps giving "File did not open! Program terminating!! " the message I included.
what am I supposed doing wrong?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
