All submissions

Union Extract Bytes from a 32-bit Value

Code

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

typedef union {
    uint32_t value;
    uint8_t bytes[4];
} Register;

// Write logic here to extract bytes using union
void print_bytes(Register input) {
    // Your code here
   
    for(int i = 0 ; i < 4; i++){
        printf("%d ", input.bytes[i]);

    }
    
}

int main() {
    Register num;
    scanf("%u", &num);
    print_bytes(num);
    return 0;
}

Solving Approach

 

 

 

Loading...

Input

305419896

Expected Output

120 86 52 18