boost之format库,格式化输出
来源:互联网 发布:linux强制退出vi q! 编辑:程序博客网 时间:2024/06/06 13:00
示例代码:
#include <iostream>#include <string>using namespace std;#include <boost/format.hpp>using namespace boost;int main(int argc, char*argv[]){//顺序不必一致format fmter("%2% %1%");fmter % 100;fmter % 200;cout<<"fmter:"<<fmter<<endl;//可重用fmter % 11;fmter % 22;cout<<"fmter:"<<fmter<<endl;//可直接转为字符串string s = fmter.str();cout<<"s:"<<s.c_str()<<endl;string s2 = str(format("%2% %1% %2% %1%") % "World" % "Hello");cout<<"s2:"<<s2.c_str()<<endl;//可以使用printf指示符cout<<format("%3.1f, %d") % 3.2 % 8<<endl;//其他用法cout<<format("(x,y) = (%+5d, %+5d)") % -23 % 35<<endl;cout<<format("(x,y) = (%|+5|, %|+5|)") % -23 % 35<<endl;cout<<format("(x,y) = (%1$+5d, %2$+5d)") % -23 % 35<<endl;cout<<format("(x,y) = (%|1$+5|, %|2$+5|)") % -23 % 35<<endl;return 0;}
输出结果:
- boost之format库,格式化输出
- Boost学习之格式化输出--format
- BOOST库 之 format输出流
- boost::format(字符串格式化库)
- boost::format 控制格式化输出 和CString::Format类似
- boost库之format
- BOOST库之format
- boost format字符串格式化
- python格式化输出函数之format
- 格式化输出函数: Format
- erlang: format 格式化输出
- 格式化format()输出字符串
- String.format() (格式化输出)
- python-格式化输出-format
- 格式化format()输出字符串
- boost posix_time格式化输出
- 使用Boost中的Format格式化标准模版库的string
- 格式化输出字符串之Format、IFormattable、IFormatProvider、ICustomFormatter
- Android模拟器键盘操作,快捷键操作
- TreeMap排序相关
- hdu1205-吃糖果
- google ProtoBuf开发者指南(比xml和jason都好的协议)
- java中数组与List相互转换的方法
- boost之format库,格式化输出
- [android深入学习]android窗口管理机制
- 第三章数程序设计初步--分支结构项目1分段函数求值
- 遍历Sd卡目录中所有子文件【可筛选特定类型文件】
- 获得document的iframe时有两种方法
- Oracle 使用ROWNUM分页时的排序问题
- View, ViewGroup, widget, LinearLayout等layout
- 关于Arrays的asList()
- 修改Google Chrome浏览器背景颜色的方法