Skip to content

Instantly share code, notes, and snippets.

@kumpeishiraishi
Created May 9, 2018 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumpeishiraishi/6253be6be4acf3efa370201172fd9403 to your computer and use it in GitHub Desktop.
Save kumpeishiraishi/6253be6be4acf3efa370201172fd9403 to your computer and use it in GitHub Desktop.
set width and set fill
#include <iostream>
#include <iomanip>
#include <sstream>
int main() {
int t = 58;
std::ostringstream ss;
ss << std::setw(5) << std::setfill('0') << t;
std::cout << ss.str() << std::endl; // -> '00058'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment