flyfish

利用boost的format

头文件

#include <boost/format.hpp>
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格式化输出方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持悠悠之家。

点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部