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它时打印 4294967295 而不是 255。
%u
使用%hhu转换规范:
%hhu
printf("%hhu, ", packet[i]);
如果您正在打印字节,您还可以考虑使用 %02X 打印十六进制