Skip to content

Instantly share code, notes, and snippets.

@csullivan
Created January 7, 2016 15:07
Show Gist options
  • Save csullivan/10429863c5911cc12a7a to your computer and use it in GitHub Desktop.
Save csullivan/10429863c5911cc12a7a to your computer and use it in GitHub Desktop.
iostream width and fill (leading zeros)
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