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 << ?
Printable View
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 << ?
Hi,
you have to use
cout << fixed(2) << var;
to display only 2 number after the decimal point
Marc