No dobra w zasadzie wpadlem na to:
struct byte_number{
unsigned int byte_1:8;
unsigned int byte_2:8;
unsigned int byte_3:8;
unsigned int byte_4:8;
};
union all_byte{
unsigned int number;
struct byte_number x;
};
i teraz jak zrobie manewr:
union all_byte x_byte;
unsigned int y=1;
x_byte.number=y;
printf("%d\n",x_byte.x.byte_1);
printf("%d\n",x_byte.x.byte_2);
printf("%d\n",x_byte.x.byte_3);
printf("%d\n",x_byte.x.byte_4);
To wychodzi co chcialem.
Tylko niech ktos mi powie wrzuce liczbe 1094861636 i dostaje 68 67 66 65 to jest dobrze tylko jak on to liczy?
Binarnie to jest tyle 0100 0001 0100 0010 0100 0011 0100 0100 wiec jesli int ma 4 bajty zatem np wartosc 68 to wartosc 1 bajta jak rozumiem zatem 8 bitow wiec biorac ustawienie 0100 0001 to z czego to wychodzi?