View Single Post
Old 07-18-2005, 12:43 PM   #5 (permalink)
billys
Upright
 
Location: Chester, UK
My C is a bit rusty but sprintf is your friend here.

Try:

Code:
char buffer[10];
for(int i=0; i<10000; i++) {
  sprintf(buffer, "%05d.png", i);
  /* write file contents */
}
the %05d is a format string that tells the compiler to format a string containing a decimal integer (the d) to a width of 5 characters (the 5) and to pad using a 0 character (the 0) and then to append that with .png.

I dont have a C compiler anymore so I cant test this but it should be right, google will find you literally hundreds of guides to format strings with printf and sprintf though.

Hope this helps
billys is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37