Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add the preprocessors required to give the compiler the instruction to compile the program. int main() { string filename = prices.txt; // put the filename

Add the preprocessors required to give the compiler the instruction to compile the program.

int main()

{

string filename = "prices.txt"; // put the filename up front

ofstream outFile;

outFile.open(filename.c_str());

if (outFile.fail())

{ cout << "The file was not successfully opened" << endl;

exit(1);

}

// set the output file stream formats

outFile << setiosflags(ios::fixed)

<< setiosflags(ios::showpoint)

<< setprecision(2);

// send data to the file

outFile << "Mats " << 39.95 << endl

<< "Bulbs " << 3.22 << endl

<< "Fuses " << 1.08 << endl;

outFile.close();

cout << "The file " << filename

<< " has been successfully written." << endl;

return 0;

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

Question Can any type of stock or securities be used in an ESOP?

Answered: 1 week ago

Question

Question Can a self-employed person adopt a money purchase plan?

Answered: 1 week ago