Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Jonbca

Char

This topic is 5820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m wortk throught the NeHE''s openGL tutorials right now and I''m trying to settup something so I can go like this int index; for (index=0;index<=6;index++) { LoadBmp("smiles"+index+".bmp") ... } so that I can use a group of bmp named smiles1.bmp smiles2.bmp ... but I don''t know how to do this using the char variable type. Any help would be great.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
strcat

Share this post


Link to post
Share on other sites
Declare a char array, like char filename[32];
In your loop:
sprintf(filename, "smiles%i.bmp", index);
LoadBmp(filename);


edit:using strcat would require you to also use either atoi or itoa (forgot which one), sprintf would be easier

[edited by - atcdevil on July 16, 2002 3:09:33 PM]

Share this post


Link to post
Share on other sites
I think something like this should work:


for (int i=0; i<=6; i++) {
char filename[256];
sprintf(filename, "smiles%i.bmp", i);
LoadBmp(filename);
...
}


I tried it using strcat, but I can't remember how to convert an integer to a string (I remember converting a string to an integer, but not the other way around).

Matt

P.S. Be sure to look up sprintf() in your documentation. Don't just use the code--understand it.

Huh...someone else already posted the answer. Nuts.

[edited by - CoderForChrist on July 16, 2002 3:19:30 PM]

Share this post


Link to post
Share on other sites
Yes, std::string would be much simpler.

/*=========================================*/
/* Chem0sh */
/* Lead Software Engineer & Tech Support */
/* http://www.eFaces.biz */
/*=========================================*/

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!