Question: 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

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!