Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,024 questions

51,976 answers

573 users

How to print 4-byte integer byte by byte in C

1 Answer

0 votes
#include <stdio.h>

int main() {
    unsigned int n = 1150336788;
    unsigned char* p = (unsigned char*)&n;
    
    printf("Integer hex value: 0x%08X\n", n);
    
    printf("Byte by byte: %u %u %u %u\n", *p, *(p + 1), *(p + 2), *(p + 3));
    
    return 0;
}

// 14 hex = 20 dec
// BF hex = 191 dec
// 90 hex = 144 dec
// 44 hex = 68 dec

 
 
/*
run:
 
Integer hex value: 0x4490BF14
Byte by byte: 20 191 144 68
 
*/

 



answered Jul 28, 2024 by avibootz
edited Jul 28, 2024 by avibootz

Related questions

...