xneo27
asked on
setprecision wrong output c++
Heres my code:
outFile << left << setw(12) << database.Record1.id
<< setw(20) << database.Record1.lastAmoun t
<< setw(15) << database.Record1.transCoun t
<< "$" << setprecision(2) << database.Record1.total << endl;
database.Record1.total is a double and i want it to output like $90.77
this is what I get:
300 30.77 3 $91
does anyone know why this happens?
outFile << left << setw(12) << database.Record1.id
<< setw(20) << database.Record1.lastAmoun
<< setw(15) << database.Record1.transCoun
<< "$" << setprecision(2) << database.Record1.total << endl;
database.Record1.total is a double and i want it to output like $90.77
this is what I get:
300 30.77 3 $91
does anyone know why this happens?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oops i meant outFile.precision(2);
outFile << left << setw(12) << database.Record1.id
<< setw(20) << database.Record1.lastAmoun
<< setw(15) << database.Record1.transCoun
outFile.precision(5);
outFile << "$" << setprecision(2) << database.Record1.total << endl;