What c++ function can I use to print a value with a fixed number of digits? For instance 9 would be printed as 09.
What c++ function can I use to print a value with a fixed number of digits? For instance 9 would be printed as 09.
silk.odyssey
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.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
Thank you hk_mp5kpdw,
setfll and setw does it for me
silk.odyssey