Reputation: 7550
I've got an array of six uint16_t
which is actually three uint32_t
, with the bits in the right order and all. How can I cast the former to the latter as effectively as possible?
The number of elements in the array is known at compile-time.
Upvotes: 4
Views: 2824
Reputation: 613342
Like this perhaps:
uint16_t arr16[6];
uint32_t *parr32 = (uint32_t*)(&arr16);
And now you can use parr32[i]
to refer to elements of the overlayed arr16
array.
Upvotes: 12