数字转为指定位数字符串
❯C++
#include <sstream> // ostringstream
#include <iomanip> // setw setfill
#include <iostream> // cout endl
int main() {
int id = 500;
std::ostringstream oss;
oss << std::setw(8) << std::setfill('0') << std::to_string(id);
std::string str = oss.str();
std::cout << str << std::endl;
}