Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It works because C structs are just contiguous bits of memory, interpreted as various fields

Well... almost. C structs can have internal padding -- but the C standard doesn't allow padding before the first element, so that first element is guaranteed to begin at the beginning of the struct.



Thanks! You learn something every day :)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: