RedditPP Mascot

RedditPP

r/C_Programming • … • u/Salat_Leaf

How to cast a certain array type to other array type?

Suppose you initialize a byte array to make it endian-independent by directly giving an order of your bytes:

```c

uint8_t a1[4] = { 0x01, 0x02, 0x03, 0x04 };

```

Is it possible in some way to cast this array type to, say, `uint16_t[2]` at compile tome? The syntax of the direct cast is invalid. I'm using C23 currently, for that matter.

— 0