fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <iomanip>
  4.  
  5. int main()
  6. {
  7. int num = 1;
  8. std::ostringstream ss;
  9. ss << std::setfill('0') << std::setw(3) << num;
  10. std::string filename = ss.str() + ".txt";
  11. std::cout << filename << std::endl;
  12. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
001.txt