Last active
May 18, 2018 02:33
-
-
Save kumpeishiraishi/590e8bfba0f8bf7e75fb4f17d5e66d57 to your computer and use it in GitHub Desktop.
Another way to set width
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
#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