Skip to content

Instantly share code, notes, and snippets.

@kumpeishiraishi
Last active May 18, 2018 02:33
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/590e8bfba0f8bf7e75fb4f17d5e66d57 to your computer and use it in GitHub Desktop.
Save kumpeishiraishi/590e8bfba0f8bf7e75fb4f17d5e66d57 to your computer and use it in GitHub Desktop.
Another way to set width
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
int main() {
std::stringstream ss;
for (int i=0; i<15; i++) {
ss << std::setw(2) << std::setfill('0') << i;
std::cout << ss.str() << std::endl;
ss.str("");
ss.clear(std::stringstream::goodbit);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment