Quote:Original post by Jazonxyz
sprintf(StringX,"%d",IntX);
The OP specified C++. Idiomatic C++ uses std::string for text.
Quote:Original post by Jazonxyz
sprintf(StringX,"%d",IntX);
Quote:Original post by superdeveloper
A little odd, but why has no-one yet mentioned itoa()?
personally I use _itot(...).
Quote:Original post by Jazonxyz@The OP: Since you're programming in C++, I would suggest following SiCrane's suggestion instead.
Its pretty simple.
First make a char.
----------------------
char StringX[5];
----------------------
next call sprintf();
----------------------
sprintf(StringX,"%d",IntX);
-------------------------
This gets String X and fills it up with IntX. Dont mind the "%d" its just a parameter.
-------------------------
int other words, this is what you need.
int iMouseX = GetMouseX() //I guess you already got that far...
char szMouseX[5];
sprintf(szMouseX,"%d",MouseX);
MessageBox(NULL,szMouseX,"ERROR",MB_OK);
Hope this helps more then it hurts
Quote:Original post by SiCrane
You can either use boost::lexical_cast or a std::stringstream.std::stringstream sstr;sstr << my_int;std::string str1 = sstr.str();std::string str2 = boost::lexical_cast<std::string>(my_int);
Once in a string, you can use the c_str() member function to get a const char *.