2
votes

Can CString::Format() receive const std::string?

Example:

void some_func( const std::string a_string )
{
    CString b_string("World");

    CString c_string;
    c_string.Format("%s %s!", a_string, b_string);

    /* print c_string */
};
2

2 Answers

5
votes

No. You need to use the return value from a_string.c_str() (which is a const char* that CString can understand).

1
votes

You can convert the std::string to a CString:

CString a_cstring( a_string.c_str() );

Then use a_cstring.

c_string.Format("%s %s!", a_cstring, b_string);