creating a new file but with automatically generated names
hi guys, its me again!!
i managed to create a file with a name of "1.txt"
what i want is to add 10 digits(which i can do), close the file and open a new one, do the same and so on.
up to a max of of 23 files.
the names of the files must be sequentially rising i.e.
1.txt
2.txt
3.txt
........
23.txt
this is the code, i have so far
Code:
#include <stdio.h>
#define MAX 10
int main()
{
FILE *f;
int x;
f=fopen("out.txt","w");
if fopen="out.txt"
f=fopen("out1.txt","w");
if (!f)
return 1;
for(x=1; x<=MAX; x++)
fprintf(f,"%d\n",x);
fclose(f);
return 0;
}
could anyone give me a hint!?
thanks :D