need help!

as usual we could use "for" with "printf" like this :

for (i=0 ; i<= 9 ; i++)
{
printf("%d\n", i);
}

can we use "for" with "fout" ,so we could create many files automatically?

like this (but it's wrong syntax):

FILE *Fout;

Fout = fopen ("result %d.txt", "w", i);
for (i=0 ; i<= 9 ; i++)
{
Fout = fopen ("result %d.txt", "a", i);
fclose(Fout);
}

Thanks a lot :)
I don't have a compiler, but I don't see any reason not...why don't you write a program and see if it works?

Actually, if it works the same as C++, you need a new output file variable for each open file, and since C isn't a reflexive language...that would make sense why you can't do it.
Last edited on
i doesn't work. Can anyone give me some advices?
Look here:
http://cplusplus.com/reference/clibrary/cstdio/sprintf/

But this is all C, not C++.
Topic archived. No new replies allowed.