The Boost Format document says:
One of its goals is to provide a substitute for printf, which means the format can parse the format string intended for printf, apply it to the given arguments and get the same result as printf.
When I compare the output of boost: format and printf using the same format string, I get different outputs. Online example here
#include <iostream>
#include <boost/format.hpp>
int main()
{
boost::format f("BoostFormat:%d:%X:%c:%d");
unsigned char cr =65;
int cr2i = int(cr);
f % cr % cr % cr % cr2i;
std::cout << f << std::endl;
printf("Printf:%d:%X:%c:%d",cr,cr,cr,cr2i);
}
Output:
BoostFormat: A:A:A:65
printf: 65:41:A:65
The difference is that I want to display char as an integral type.
Why is there a difference? Is this a mistake or a desire for behavior?
source
share