boost::formatboost::format是用于替代c里面的sprintf,优点是类型安全,不会因为类型和参数不匹配而导致程序崩溃了而且还可以重复使用参数
#include < boost / format.hpp > void test_format() { cout << boost::format( " writing %1%, x=%2% : %3%-th try " ) % " toto " % 40.23 % 50 << endl; format f( " a=%1%,b=%2%,c=%3%,a=%1% " ); f % " string " % 2 % 10.0 ; cout << f.str() << endl;}