I wasn't even sure if the topic question is right...but here's my question
Say I have object:
1 2 3 4 5
|
struct Test{
int a;
char b,c,d;
};
|
Now whenever I declare this object, the 4 bytes of int and 3 byte of char will be sitting side by side in memory as well as some extra padding due to compiler preference to end data types on 4 byte boundaries (so we're really at 8 bytes here)
I want to create a mask of say long long int, 8 bytes of int.. I create my mask and now...I am confused, how do I apply my long long mask to Test type?
I know of the bitwise operators | ~ & etc. That isn't the issue, the issue is, I want to use my long long as a way to mask the whole Test object, meaning at << 32, I am attempting to mask char b (as that would exist on the 5th byte).
I know in memory the int and char bytes are sitting right next to each other, so it should be possible to access all of them with a single mask that is large enough to do so.
Is there a way of doing this without casting my Test obj to another type?