【发布时间】:2009-02-10 00:00:24
【问题描述】:
如何在 C++ 中格式化我的输出?换句话说,什么C++相当于像这样使用printf:
printf("%05d", zipCode);
我知道我可以在 C++ 中使用 printf,但我更喜欢输出运算符 <<。
你会用下面的吗?
std::cout << "ZIP code: " << sprintf("%05d", zipCode) << std::endl;
【问题讨论】:
标签: c++ formatting numbers