Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
XC8 コンパイラを搭載した PIC18 デバイスでこのコードを使用しています。
printf("%x", (unsigned char) some_value);
some_valueが 未満の場合0xf0、たとえばc値 12 の場合は 1 桁のみが出力されます。 より大きい値の場合、たとえば値 66 の場合0x0fは 2 桁が出力されます。42
some_value
0xf0
c
0x0f
42
printf()以下の値でも、2文字を強制的に出力する方法はあります0xf0か?
printf()
もちろん:
printf("%02x", ...);
とそのフォーマットに関するドキュメントを読んだだけであれば、それは非常に明白だったでしょう。printf
printf