変数を使用して単語幅を制御したいと考えています。で可能boost::format
ですか?はlen
実行時に決定されます。
例:
string a="a",b="bb",c="321";
int len = 4;
cout << boost::format("%1% %|%2%t|%3% \n") % a % len % c;
cout << boost::format("%1% %|%2%t|%3% \n") % b % len % c;
//cout << boost::format("%1% %|4t|%2% \n") % b % c; // I know this works.
プリントアウト:
a 321
bb 321