This might seem a very stupid question but how is the member access operation in struct performed?
When you write struct_name.member_name how does the machine know which member to be accessed?
Structs are stored in a contiguous block of memory with some padding(depends) and there is no sort of mapping of member identifiers to memory locations afaik.
Unlike arrays, structs cant be accessed using base address offset and size (am I right?) so how does it happen ?
Does the access take O(1) or not and what is the reason for it?
struct, in accordance with the C Standard's rules. So it knows what the offset of each member is. Whether the compiler uses an instruction that contains an offset from the base, or whether it is able to compute the actual address of the member, is an implementation detail.