如何打印5字节整数值?

ssi*_*sin 0 c

我刚开始阅读C并对宏有疑问.
如何打印5字节整数值(恰好在宏中定义)?例如:

#define MAX 0xdeadbeaf12
int main(){
printf(" 0x %2x \n", MAX);
}  
Run Code Online (Sandbox Code Playgroud)

此代码打印adbeaf12但不打印deadbeaf12.

如何打印所有字节?

nal*_*all 5

我更喜欢对变量显式的大小做出假设.以下使用标准(但通常未使用)宏来定义64位常量并将此数量打印为十六进制值.

#include <stdio.h>

// Pull in UINT64_C and PRIx64 macros
#include <inttypes.h>

// Make this a 64-bit literal value
#define MAX UINT64_C(0xdeadbeaf12)

int main()
{
    // Use PRIx64 which inserts the correct printf specifier for
    // a hex format of a 64-bit value
    printf(" 0x%" PRIx64 " \n", MAX);
}
Run Code Online (Sandbox Code Playgroud)