Output from multiple variables

Hello everybody on Cplusplus.com,

I'm in the process of writing a win32 program in Dev-C++ distributed by Orwell. In relation to that a problem has occurred. When I'm writing a program in C++ console, I write the following code to output multiple variables:

cout << "The value of x is: " << x << " and the value of y is: " << y << endl;

When I want a output, I for instance write the following code:

CreateWindow("STATIC", text, WS_VISIBLE | WS_CHILD, x, y, h, w, hwnd, (HMENU) ID, NULL, NULL);

The this case I use the text as a variable. My question is now, how do I output from more than one variable and get the same result as with the console?

My guess was something like CreateWindow("STATIC", "Here is the text: " text | " and the other text: " text2, WS_VISIBLE | WS_CHILD, x, y, h, w, hwnd, (HMENU) ID, NULL, NULL); - but I know that's not how you do it.

Can you guys please help me?
Last edited on
std::ostringstream os;
os << "The value of x is: " << x << " and the value of y is: " << y << endl;
std::string text = os.str();

CreateWindow("STATIC", text.c_str(), WS_VISIBLE | WS_CHILD, x, y, h, w, hwnd, (HMENU)ID, NULL, NULL);
Last edited on
The GDI analog to printing to a console window is TextOut() or DrawText(). And actually, those functions also work with consoles too. Consoles have a HWND, which is the key to getting that to work.
kbw: Thank you very much! It worked!

freddie1: Thank you, I will take a look and see which solution works best.
Topic archived. No new replies allowed.