Boost 入门之3 - 格式化
原创
©著作权归作者所有:来自51CTO博客作者wx5fc8832a61484的原创作品,请联系作者获取转载授权,否则将追究法律责任
// boost_.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <boost/format.hpp>
using namespace std;
//类似c的sprintf,MFC的Format.
int _tmain()
{
cout << boost::format("%2.3f, %d,%s") % 1.23456 % 12 % "test" << endl;
boost::format fmt = boost::format("%s %d ") % "123" % 57;
std::string s = fmt.str();
cout << s << endl;
cout << boost::format("x=%1%, y=%2% ,z= %3%") % "test" % 40.2 % 134 << endl;
getchar();
return 0;
}