Created
May 11, 2021 13:47
-
-
Save kaityo256/c3f69663e6d1f0322d48bebbc31430ab to your computer and use it in GitHub Desktop.
連番ファイル名を作る方法
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 <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