prog_avancee_C/TP4/union_ex1.c
2024-10-22 13:03:17 +02:00

30 lines
473 B
C

#include <stdio.h>
typedef union int_test {
int a;
char b[4];
} test;
void print_hex(int n);
int main(int argc, char *argv[])
{
/*test i = {.a=429496729};
for(int j=0; j<4; j++){
printf("%d ", i.b[j]);
}
printf("\n");*/
print_hex(14*256 + 11*16 + 8);
print_hex(4*256 + 2*16 + 0);
return 0;
}
void print_hex(int n) {
test i = {.a=n};
for (int j=0; j<4; j++) {
printf("%d ", i.b[j]);
}
printf("\n");
}