Jonathan Livni
Jonathan Livni

Reputation: 107062

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

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 */
};

Upvotes: 2

Views: 3228

Answers (2)

Zac Howland
Zac Howland

Reputation: 15872

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

Upvotes: 5

SwDevMan81
SwDevMan81

Reputation: 49978

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);

Upvotes: 1

Related Questions