Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost::format hex output

I'm using boost::format to create and format a string.

I would like to create following output:

Data: 0x64 - Name: 'xxx', Value: 10

I tried it with following line:

boost::format("Data:  %|02x|%1% - Name: '%2%', Value: %3%") % code % name % value);

but it doesn't work.

I know that the formation of the first parameter is wrong, but I am not able to fix it.

Is there a possibility to print the first parameter as hex?

like image 726
MeJ Avatar asked Jun 23 '14 10:06

MeJ


1 Answers

Just use

boost::format("%1$#x")

this means - output first argument in hex form with numerical base.

More information here

like image 69
ForEveR Avatar answered Oct 29 '22 11:10

ForEveR