首页 > 编程 > C++ > 正文

C++ string格式化输出方式

2020-01-26 13:21:40
字体:
来源:转载
供稿:网友

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表