How to elegantly simplify (or eliminate) the for loops in the code below, using C++17 features ?
#pragma pack(push, 1)
typedef struct ethernet_frame
{
unsigned char dst[6];
unsigned char src[6];
unsigned short proto;
} ethernet_frame, *ethernet_frame_ptr;
#pragma pack(pop)
int i;
ethernet_frame eFrame = { {00,00,00,00,00,00}, {42, 54, 33, 67, 14, 88}, 0x800 };
ProcessFrame(&eFrame); //A library function expecting an address of an ethernet_frame with its strict bit layout
i = 0;
for (unsigned char c : { 36, 84, 23, 77, 35, 11 }) eFrame.dst[i++] = c;
ProcessFrame(&eFrame);
i = 0;
for (unsigned char c : { 65, 23, 74, 82, 20, 94 }) eFrame.dst[i++] = c;
ProcessFrame(&eFrame);
i = 0;
for (unsigned char c : { 47, 22, 86, 45, 33, 38 }) eFrame.dst[i++] = c;
ProcessFrame(&eFrame);
// etc...
Reassignments like eFrame.Dst = { 47, 22, 86, 45, 33, 38 } would be neat ...but they are illegal :(