代码之家  ›  专栏  ›  技术社区  ›  xiekuan

如何在C中打印ext2超级块的s_uuid

  •  0
  • xiekuan  · 技术社区  · 7 年前

    我创建了一个变量来存储超级块的s_uuid的值。但是我遇到了麻烦,无法在这个表单中打印这个变量,比如xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx。我试图在%x和%s中使用printf来打印变量,但它不起作用。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Bart Bartel    7 年前

    SU uuid在超级块中定义为:

    要以上述格式将其打印到控制台:

    uint8_t s_uuid[16] = {0xf3, 0x58, 0x6b, 0xaf, 0xb5, 0xaa, 0x49, 0xb5, 
                          0x8d, 0x6c, 0x05, 0x69, 0x28, 0x4c, 0x63, 0x9f};
    
    printf("%02x%02x%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
        s_uuid[0], s_uuid[1], s_uuid[2], s_uuid[3], s_uuid[4], s_uuid[5], s_uuid[6], s_uuid[7], 
        s_uuid[8], s_uuid[9], s_uuid[10], s_uuid[11], s_uuid[12], s_uuid[13], s_uuid[14], s_uuid[15]);