How can I format my output in C++? In other words, what is the C++ equivalent to the use of printf
like this:
printf("%05d", zipCode);
I know I could just use printf
in C++, but I would prefer the output operator <<
.
Would you just use the following?
std::cout << "ZIP code: " << sprintf("%05d", zipCode) << std::endl;