How to print hex value in chunks using char* with C

1 Answer

0 votes
#include <stdio.h>
#include <stdint.h> 

int main(void)
{
    uint32_t hex = 0x01020304;
    char* p = (char*)&hex;

    // Intel: little-endian  
    printf("%x %x %x %x\n", p[0], p[1], p[2], p[3]);

    return 0;
}



/*
run:

4 3 2 1

*/

 



answered Jul 9, 2024 by avibootz

Related questions

1 answer 54 views
2 answers 47 views
47 views asked Dec 2, 2024 by avibootz
1 answer 45 views
1 answer 33 views
...