Govt Exams
In C, self-referential structures require the struct keyword in pointer declarations within the structure definition.
Both methods are valid - A uses named struct tag with variable declaration, C uses anonymous struct with variable declaration.
Union size equals the largest member size. float is typically 4 bytes, which is largest.
typedef creates an alias for the struct type, allowing direct use without 'struct' keyword.
struct Point { int x; int y; };
struct Point p = {5};
printf("%d %d", p.x, p.y);
When initializing a struct with fewer values than members, remaining members are zero-initialized. p.x=5, p.y=0.
Structures allow you to combine multiple data types into a single composite type, making code organization and data management more efficient.
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.
A self-referential structure contains a pointer to its own type, commonly used in creating linked lists, trees, and other data structures.