Alternative to CString :: Format?

Is there a better alternative for formatting strings in VC6 with syntax checking before replacing?

+3
source share
3 answers

CStringoffers a method Formatfor formatting printf-style, but it is not type safe.

For string formatting of strings, you can either use std::stringstream/ std::wstringstreamor Boost Format , although they both work with a C ++ class template std::basic_string, not an MFC class CString. I have successfully used both of them in VC6.

Boost , printf -like , , , , ++ iostreams .

, CString std::string :

std::string s;
CString str( s.c_str() );

, !

+10

FastFormat. "" - FastFormat , - CString.

- :

int i = 1;
std::string ss = "a std string";
CString cs = "a Cstring";

CString result;

fastformat::fmt(result, "i={0}, ss={1}, cs={2}", i, ss, cs);
+1

FormatString - -

CodeProject

0

All Articles