Hello,
How can I print a uint32_t type variable in hex? Here's my code and the output:
Code:
/* types.h */
#ifndef __MYTYPES_H__
#define __MYTYPES_H__
#include <stdint.h>
#include <inttypes.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
#endif
Code:
/* mytest.c */
#include <stdio.h>
#include "types.h"
int main() {
printf("sizeof(u32): %zu.\n",sizeof(u32));
printf("sizeof(PRIx16): %zu.\n",sizeof(PRIx16));
printf("sizeof(PRIx32): %zu.\n",sizeof(PRIx32));
printf("sizeof(PRIx64): %zu.\n",sizeof(PRIx64));
return 0;
}
and the results:
Code:
sizeof(u32): 4.
sizeof(PRIx16): 2.
sizeof(PRIx32): 2.
sizeof(PRIx64): 3.
Thanks!