Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created May 11, 2021
Embed
What would you like to do?
連番ファイル名を作る方法
#include <cstdio>
#include <cstdlib>
#include <string>
void save_data(const std::string filename) {
printf("%s\n", filename.c_str());
}
int main() {
std::string filename;
for (int i = 0; i < 100; i++) {
char buf[256];
std::snprintf(buf, sizeof(buf), "data%03d.dat", i);
filename = buf;
save_data(filename);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment