Q:

Printing text and variables in Windows C++

I'm currently working on a Windows based C++ program. I am used to working/coding console applications so I am not familiar with the syntax for a lot of what I'm trying to do. So I might have a lot more questions later on. 
For now, I want to print some text and have a variable displayed within the text. 
For example, if I wanted to print "I am X years old" and X = 30, how would the syntax of that be formed? 
I know this works: 
DrawText(hDC,L"I am X years old",-1,&rect,DT_CENTER | DT_WORDBREAK );

What I want to do is:
DrawText(hDC,L"I am "+ X +" years old",-1,&rect,DT_CENTER | DT_WORDBREAK );

But this doesn't work. So how do I correctly implement that?

A:

C++ is not a typeless language like Javascript, etc, and so you can't construct a string like that by adding the parts together. Instead you have to build the string yourself using a function like swprintf_s. For example,
wchar_t wchBuf[128];
swprintf_s(wchBuf, _countof(wchBuf), L"I am %ld years old", X);
DrawText(hDC, wchBuf, -1, &rect, DT_CENTER | DT_WORDBREAK);

