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.
printf("%d, ", packet[i]);
変数を正しく表示する方法。0 から 255 の範囲である必要がありますが、使用すると次のよう%dに出力されます。
%d
-1 として 255
128 までは正しく表示され、それ以上はマイナスになります。
使用する%uと、255 ではなく 4294967295 が出力されます。
%u
使用%hhu変換仕様:
%hhu
printf("%hhu, ", packet[i]);
バイトを印刷している場合は、%02X で 16 進数を印刷することも検討してください。