This is probably trivial question. I am not a professional programmer, I am rather a mathematician who is doing some numerical experiment using C. I would like the output of my
You could try this:
#include
#include
int main(void) {
int i = 0;
for (i = 0; i < 10; i++) {
char filename[64];
sprintf(filename, "file%d", i);
FILE *fp = fopen(filename, "w");
fprintf(fp, "%d\n", i);
fclose(fp);
}
return 0;
}
Your code is almost ok. Some observations:
sprintf
to create the name of the file. In C there is not a concatenate operator of strings.