Advertisement

String question

Started by July 28, 2002 07:08 PM
2 comments, last by Kaezin 22 years, 4 months ago
Alright I wanna load dome1.bmp, dome2.bmp, and dome3.bmp, and I want to do it in a loop. How do I do that? I''ve done it before but I don''t remember how. It was something like:

for(int iCounter=0;iCounter<=3;iCounter++)
    LoadBMP(strcat(strcat("dome",iCounter)),".bmp");
 
I doubt it is strcat, I don''t even know what I''m saying because this is all off the top of my head. Can anyone help me?
Half the people you know are below average.Trogdor the Burninator
I have no idea what this load BMP function is. It's not function VC++ help recognizes, so I'll assume it came from somewhere else. Because of that, I'm going to have to sum it up like this. Please note I have no idea how this LoadBMP function works, so you may have to change the call to it.

for (int loop = 1; loop < 4; loop++){
char name[100]; sprintf(name,"dome%d.bmp",loop);
LoadBMP(name);
}

strcat appends the second string to the first, and I really don't see the need for it if the only part that's changing is the number. If you did want to use those nested strcat functions, however, you'd have to do something about that iCounter, simply because that's an integer, not a string. Using that number would have incorrect output.

Hope this helps!

-Arek the Absolute

[edited by - Arek the Absolute on July 28, 2002 8:19:33 PM]
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
Advertisement
(beaten to it)

[edited by - Beer Hunter on July 28, 2002 8:22:05 PM]
My C++ teacher would be ashamed of me; I forgot about sprintf =P Thanks hehe
Btw it''s OpenGL
Half the people you know are below average.Trogdor the Burninator

This topic is closed to new replies.

Advertisement