need help adding text output file to program?

so after creating this program I was asked to have the answer created in an output file text. im a little lost.

#include <iostream>
#include <iomanip>
#include <string>


using namespace std;

int main()
{

int daysworked;
double dailypay = .01;
double total = 0.0;

cout << " How many days did the employee work this month? ";
cin >> daysworked;

while (daysworked < 1 || daysworked > 31)
{

cout << " Error try again !!!\n\n\n";
cout << " The number of days must be between 1 and 31.\n\n";
cout << " please re-enter days worked: ";
}

cout << "\n\n\n";

cout << "Day\t\t\tPay";
cout << "-----------------------------------\n";

cout << fixed << showpoint << setprecision(2);

for (int day = 1; day <= daysworked; day++)
{

cout << day << "\t\t\t" << dailypay << endl;

total = total + dailypay;

dailypay = dailypay * 2;

}

cout << "---------------------------------------\n";
cout << " Total $ " << total << endl << endl;

return 0;
}

Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting, as well as proper indentation.

The tutorial on this site, although somewhat dated, should be helpful:
http://www.cplusplus.com/doc/tutorial/files/
Just note that there is almost no reason to ever use .open() or .close()
Topic archived. No new replies allowed.