9 Jul
2010
9 Jul
'10
2:29 p.m.
With the following program I am trying to print the hex of "a". But it is not printing it correctly. I have gone through the boost format sysntax specification. But I dont have any clue, what am I doing wrong?
char a=0x11; stringstream ss; ss<<boost::format("%|02X|")%a; cout<<ss.str()<<endl;
Assuming your format string is correct (I haven't checked against the doc), try casting your char to int: (int)a