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

Can CString :: Format () get 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 */
};
+3
source share
2 answers

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

+5
source

You can convert std::stringtoCString:

CString a_cstring( a_string.c_str() );

Then use a_cstring.

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

Source: https://habr.com/ru/post/1786756/


All Articles