Click to See Complete Forum and Search --> : ostream


Assaf
May 5th, 1999, 06:06 AM
In C, if I want, for example, to print a variable as a floating point, at least 6 wide and 2 after decimal point, I use : printf("%6.2f", var);
How can I have the same effect on C++, using cout << ?

Marc L'Ecuyer
May 5th, 1999, 07:11 AM
Hi,

you have to use

cout << fixed(2) << var;

to display only 2 number after the decimal point

Marc