owa*_*agh 2 c++ iostream format-string
我可以使用带有printf等格式字符串的c ++ iostream类吗?
基本上,我希望能够做到这样的事情: -
snprintf (inchars, len, "%4f %6.2f %3d \n", float1, float2, int1);
Run Code Online (Sandbox Code Playgroud)
很容易使用stringstreams.是否有捷径可寻?
是的,有Boost格式库(内部是字符串流).
#include <boost/format.hpp>
#include <iostream>
int main() {
std::cout << boost::format("%s %s!\n") % "Hello" % "World";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2425 次 |
| 最近记录: |