Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

Discuss voluntary benefits.

Answered: 1 week ago

Question

Explain the process of MBO

Answered: 1 week ago