首页 > 编程技术 > C语言

C++ string格式化输出方式

发布时间:2020-4-25 17:24

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格式化输出方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持猪先飞。

标签:[!--infotagslink--]

您可能感兴趣的文章: