Hi,
I am writing a program in C that will be outputting a lot of files that I want to be named 00001.png 00002.png 00003.png and so on.
The way I am doing it at the moment is as follows:
Code:
for(i=0; i < 10000; i++)
{
filename[4]++;
if(filename[4] > 57)
{
filename[4] = 48;
filename[3]++;
if(filename[3] > 57)
{
filename[3] = 48;
filename[2]++;
if(filename[2] > 57)
{
filename[2] = 48;
filename[1]++;
if(filename[1] > 57)
{
filename[1]++;
}
}
}
}
//CODE THAT WRITES TO FILE USING filename
}
Now this seems a rather ugly way to do it. What I should be doing is simply incrementing an integer and then converting that to a string somehow, but I can't work out how to do this.
Any ideas?
Thanks
Robbie