Jump to content
  • Advertisement
Sign in to follow this  
mako_5

C++ Strings

This topic is 4557 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've found some information on appending to strings in C++ but nothing about how to add another type of data field (i.e. unsigned int) to a string. Is there a conversion method or something? (i'm still migrating over from Java) I'm trying to get a const char* to display text on screen using Irrlicht. The problem is how do I append an integer to a char*. What I'm trying to do is display a character's name followed by their HP/MP int values, but don't know how to dynamically build the display string. The display string would equal : character name + HP + MP

Share this post


Link to post
Share on other sites
Advertisement
EDIT: John wins. ;) That's what I get for sitting here doublechecking in VC++. :P

For std::strings, std::stringstreams are good:


#include <sstream>

std::stringstream s;
s << "You have " << hp << " HP and " << mp << "MP";


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!