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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started