Hi everyone,
Just a quick question. If I make my code like this:
Would this actually work as I think it will? Meaning will the union also apply the htonl() function to struct a? I tried it but I'm still not so sure if I'm correct.Code:typedef struct{ unsigned long btfd1:8; unsigned long btfd2:8; unsigned long btfd3:8; unsigned long btfd4:8; } a; typedef union{ a union_btfd; unsigned long con; } b; int main(void) { ... a structBT; b hold; b temp; hold.union_btfd = structBT; temp.con = htonl(hold.con); structBT = temp.union_btfd; return 0; }
Thanks.