What c++ function can I use to print a value with a fixed number of digits? For instance 9 would be printed as 09.
Printable View
What c++ function can I use to print a value with a fixed number of digits? For instance 9 would be printed as 09.
A combination of the setw stream manipulator and setfill would help here, to use these you must #include <iomanip>. Alternately, the output stream you are dealing (cerr, cout, etc.) has the necessary functions that you can call directly, i.e. cout.fill and cout.width.
Thank you hk_mp5kpdw,
setfll and setw does it for me :)