5 ms·
Dude, you lost me at "just use an array and fill it in". Learn about struct packing and let the compiler fill in the "array" for you. Anyway, a good way to le
by jeffrallen 2y ago
Dude, you lost me at "just use an array and fill it in".
Learn about struct packing and let the compiler fill in the "array" for you.
Anyway, a good way to learn stuff. Hard mode, FTW!
- libcheet 2y agoYes. For production, struct are obvious choice. But here arrays were similar to how documentation specified data will be on the wire. So for educational purposes (to explain protocol) it seemed like a better choice. But I might be wrong and maybe structs would have been more approachable way to understand.
- hi-v-rocknroll 2y agoC structure packing isn't portable and doesn't account for host/network endianness. Buffer byte-oriented de/ser is the primary way of assembling data in C.