sprintf("%02x", c)
I know this code converts decimal to hex but what does the “2” mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
0is the padding character, while2is a width specifier that specifies how many characters you want printed. It is intended as the minimum number of characters, so having02will always at least print 2 characters and they’ll be zero if there’s no other data to be shown.