Created
January 7, 2016 15:07
-
-
Save csullivan/10429863c5911cc12a7a to your computer and use it in GitHub Desktop.
iostream width and fill (leading zeros)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set width of integer output: | |
#include <iostream> | |
#include <iomanip> | |
int main() { | |
cout << setfill('0') << setw(2) << 5 << endl; | |
return 0; | |
} | |
output: | |
05 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment