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?
Just use
boost::format("%1$#x")
this means - output first argument in hex form with numerical base.
More information here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With