#include #include #include int main() { const int MAXLENGTH = 21; // maximum file name length char filename[MAXLENGTH] = "prices.dat"; // put the filename up front ofstream outFile; outFile.open(filename); 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 << "Batteries " << 39.95 << endl << "Bulbs " << 3.22 << endl << "Fuses " << 1.00; outFile.close(); return 0; }