Boost logo

Boost :

From: Philipp Henkel (threadpool_at_[hidden])
Date: 2006-07-18 13:44:15

Dear all,

I wondered about boost::format's printf behaviour regarding char's.
There seems to be no difference between the two format pattern "%c" and
"%d". boost::format does not interpret chars as decimal values when using

Please take a look a the following example:

 unsigned char foo = 65;
 printf("foo = %d", foo); // output is "foo = 65"

 std::string bar = (boost::format("foo = %d\n") % foo).str();
 printf(bar.c_str()); // output is "foo = A" which is what I want when using

Is this behaviour intended? From my point of view it's dangerous because
printf users
do not expect it. Furthermore it may lead to string truncations because of
terminators (char is 0) which are inserted by accident.

Did I overlook something?

I'm using boost 1.33.1 / VC8.

Best regards,

Boost list run by bdawes at, gregod at, cpdaniel at, john at