I'm new to C++ with MFC.. I want to do something like this

long longvar = 0;  

return _T("The value of longvar is " + longvar + "!");

But of course, is not allowed by C++..

Please! HELP!!! I'd really appreciate it!!

So use a std::string to evaluate the string concatenation, then return what that produces.

You'll also need the run-time equivalent of _T as well.

I'm new to C++ with MFC..

You probably will find the CString class useful. See e.g. the CString::Format() function.

hi e_pech,

possibly this works (so far, i didn't test it):

int main_string()
    long int i = 2008;
    string s;
    stringstream st;
    st << i;
    cout << "The value of longvar is " + st.str() + "!\n";
    return 0;


Salem, thank you very much! I'm using MFC. Is there a way to do it with the CString class???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.