利用boost的format
头文件
#include
boost::format f = boost::format("%.2f %s %d") % 1.234 %"123" % 12; std::string s = f.str();
等同于
boost::format f = boost::format("%.2f %s %d"); f % 1.234 %"123" % 12; std::string s = f.str();
类似CString的格式化
CString t = L"123"; CString s; s.Format(L"%.2f %s %d", 1.234, t, 12);