今天小编就为大家分享一篇C++ string格式化输出方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
flyfish
利用boost的format
头文件
#inc<b style="color:transparent">来源gao@dai!ma.com搞$代^码网</b>lude
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);
以上就是C++ string格式化输出方式的详细内容,更多请关注gaodaima搞代码网其它相关文章!