Hi, this code doesn't seem to output the file properly. Can you help? Thanks.Code:#include <iostream.h> #include <stdio.h> #include <fstream.h> #include <stdlib.h> #include <string.h> int main() { // hours for each day double mon; double tue; double wed; double thu; double fri; double sat; double sun; double totalhours = 0; double totalpayed = 0; double payrate = 6.27; char filename[256]; char totalpayed_str[256]; cout << "Enter the hours worked on the following days:\n\n"; cout << "MONDAY: "; cin >> mon; cout << "\nTUESDAY: "; cin >> tue; cout << "\nWEDNESDAY: "; cin >> wed; cout << "\nTHURDAY: "; cin >> thu; cout << "\nFRIDAY: "; cin >> fri; cout << "\nSATURDAY: "; cin >> sat; cout << "\nSUNDAY: "; cin >> sun; cout << "\n"; cout << "******************************************************\n"; totalhours = (mon + tue + wed + thu + fri + sat); // sun not added totalpayed = payrate * totalhours; totalpayed += ( sun * (payrate * 1.5) ); // time and a half on sundays totalhours += sun; // add sun into the total hours becuase it was missed cout << "You will be payed $" << totalpayed << " for working " << totalhours << " hours this week.\n"; // print out file ---------------- _gcvt(totalpayed, 5, totalpayed_str); strcpy(filename, "C:\\"); strcpy(filename, "Getting paid "); strcpy(filename, totalpayed_str); strcpy(filename, " this week.txt"); ofstream outfile(filename); outfile << " "; outfile.close(); return 0; }



LinkBack URL
About LinkBacks


