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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!