C++ で zfill
この記事は 12 年以上前に書かれたものです。内容が古くなっている可能性があります。
C++ で Python の zfill みたいな関数を作る.連番でフォルダ名とかを指定するときに便利です.
std::string zfill(const std::string& str, const int width)
{
std::stringstream ss;
ss << std::setw(width) << std::setfill('0') << str;
return ss.str();
}