Govt Exams
Bit fields allow you to specify the number of bits for integral members, enabling memory optimization by packing multiple small values into a single byte.
Since union members share memory, modifying one member overwrites the value of other members because they occupy the same memory location.
Structure arrays are initialized with nested braces, where each set of braces contains initialization values for one structure element.
Structures allow you to combine multiple data types into a single composite type, making code organization and data management more efficient.
For nested structures accessed through an object, use the dot operator multiple times: obj.in.value accesses the value member of the inner structure.
sizeof(int) = 4 bytes, sizeof(pointer) = 8 bytes (on 64-bit systems). Total = 12 bytes. Pointers are fixed size regardless of what they point to.
Due to padding: int (4) + padding (4) + double (8) + char (1) + padding (3) = 24 bytes. The structure aligns to the largest member size.
The arrow operator (->) is used to access structure members through a pointer. It dereferences the pointer and accesses the member in one operation.
Padding adds unused bytes between members to align them on word boundaries, improving CPU access efficiency and performance.
The typedef keyword creates an alias for a data type, allowing you to use a shorter name instead of the full struct declaration.