用户登录
用户注册

分享至

C++ string格式化输出方式

  • 作者: 温柔男神帅帅哒
  • 来源: 51数据库
  • 2020-07-30
今天小编就为大家分享一篇C++ string格式化输出方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

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

软件
前端设计
程序设计
Java相关