Thomas J. Gritzan
10/1/2008 8:33:00 PM
> jdk0118@gmail.com wrote:
>> So I am making some code that shows your mouses X and Y coordinates.
>> As of now I am doing it via command line and I have to press enter.
>>
>> How would I got about putting it in a MessageBox() ?
>> I tried it but I can't put the variable in..
asm23 wrote:
> It's a platform related topic. You'd better try some *windows* related
> group.
How to call MessageBox is platform specific, but the OP obviously
wanted to build a string and pass the string to MessageBox().
Let's assume that MessageBox takes a const char*, you could use a
std::ostringstream like this:
#include <sstream>
#include <string>
// a function that takes a C-style string
void SomeFunction(const char*);
int main()
{
float x = 0;
float y = 0;
std::ostringstream message;
message << "X: " << x;
message << "\n";
message << "Y: " << y;
// build temporary std::string from stringstream,
// get const char* from std::string,
// then call your function:
SomeFunction( message.str().c_str() );
}
--
Thomas