|
Save_bitmap loop |
Eradicor
Member #2,992
December 2002
|
Ok. Dont ask why i need following, program code. Just suffice to say, i need it: I need something like this -> while(x = 1000) { Now it should do 1000 bmp files containing certain_bitmap and the file names should be: certain1.bmp And for curious, no this is not for making screen capturing, but is ment for very special kind of animation program for our next film project. FAST ANSWERS PLEASE.. And correct too! | Visit The site | |
Mokkan
Member #4,355
February 2004
|
Like this? int x = 1; while(x <= 1000){ char filename[64]; sprintf(filename, "certain%d.bmp", x); draw_certain_bitmap_full_of_stuff(); save_bitmap(certain_bitmap, filename); x++; } EDIT: Fixed code.
|
Onewing
Member #6,152
August 2005
|
Quote: FAST ANSWERS PLEASE.. And correct too! Sure! As soon as I find the question... ------------ |
CGamesPlay
Member #2,559
July 2002
|
Don't forget to increment x [append] -- Ryan Patterson - <http://cgamesplay.com/> |
Jonatan Hedborg
Member #4,886
July 2004
|
First i considered not answering, because of your well, arrogant, tone. But what the hey, i feel like "giving". And you obviously dont have any idea what you are doing. for(int i=1; i<=1000; i++) { draw_certain_bitmap_full_of_stuff(certain_bitmap); char tmp[256]; sprintf(tmp,"certain%i.bmp",i); save_bitmap(certain_bitmap,tmp); } Untested, naturally, so i can't give any guarantees, but that should do it.
|
ReyBrujo
Moderator
January 2001
|
I would use %04d instead, to get 0001, 0002, 0003, etc. But it is just my taste. -- |
A J
Member #3,025
December 2002
|
i would be more concerned with people still using sprintf hasn't the last 3 years of "secure" programming hyperbole from just about everyone meant anything? and whats with using file[64] and file[256] ? how about using MAX_PATH and what about clearing it before using it ? ___________________________ |
Jonatan Hedborg
Member #4,886
July 2004
|
I heard it mentioned that sprintf is "bad" in some way. Please elaborate =)
|
Evert
Member #794
November 2000
|
Quote: I heard it mentioned that sprintf is "bad" in some way. Please elaborate =) Buffer overruns. It doesn't check if it writes outside the size of the allocated memory buffer (because you don't tell it the size of the memory buffer). Quote: You don't need to clear it afaik Correct. |
Jonatan Hedborg
Member #4,886
July 2004
|
Right. That would be bad. But it's not an issue here anyway.
|
A J
Member #3,025
December 2002
|
Bad code is always an issue. ___________________________ |
Eradicor
Member #2,992
December 2002
|
Jonatan Hedborg said: First i considered not answering, because of your well, arrogant, tone. Heh thats new. Well when you are on a hurry you dont have luxuary of being polite. Anyway i solved this problem another way. Thanks however. That filename routine comes handy else where tho. | Visit The site | |
|