This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SPRINTF %2bx give me 0 instead of 00

I have an unsigned char that I am converting to string and I want exactly 2 hex characters regardless of the value in the char.

myvalue = 0;
sprintf( ptr, "MyValue=%2bx",myvalue);
results in:
MyValue=0
but I want
MyValue=00

The leading zero is never printed. I thought the 2 which is supposed to be with width would force it to always print 2 characters.

Is there some other trick?

0