How do I number files?

Hello community,
I'd like to know how I can number files, created by a programm. I imagined it like this:
Every time the programm creates a file it counts how many there are already in the directory and saves it to a variable (let's say int i). The new file should be saved as "save"+i+".txt". The directory should look like this:

1
2
3
save0.txt
save1.txt
...


Now my questions:
How can I count the files?
How can I insert the number of files in the filename?

PS: Sorry for my English, I come from Germany ;)
I can help with the counting part, you need to use a for loop and possibly arrays

example of the for loop:

for(int i = 0; i < size; i++)//i set to 0, i is under a variable or array, i gets 1+
{
size[i] = i;
}

an easy way out would be to make the program save as numbered files and not save0, 1, 2, etc. such as 000.txt, 001.txt, etc

i can't help you very much without seeing and debugging the program for myself :P
Topic archived. No new replies allowed.