unsigned char alpha;
unsigned char red;
unsigned char green;
unsigned char blue;
};
to an int in C++?
i may not answer the question but what do u mean to int isnt char already int(number)
He wants to pack the whole structure into a single int variable
like alpha 4 red 5 green 6 blue 7 and the new var will hold 4567 ?
into a 32 bit int?
Depend, for RGBA unsigned color=((unsigned)R<<24)|((unsigned)G<<16)|((unsigned)B<<8|(unsigned)A;
damn it is definitely easier in rust
union color struct { unsigned char alpha; unsigned char red; unsigned char green; unsigned char blue; } unsigned color; };
i would like to avoid that, :P
this is the correct way
It is not sizeof(int) * CHAR_BIT is not necessarily equals to 32
I'm not taking that into account
No just a normal int
There should be macro for library. To conform format/endianess.
Don't do it int isn't fixed size so it can fuck things up.
There is and I found it
Обсуждают сегодня