We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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?
Without the leading 0 in the formatting string, you get space as pad character.