Govt. Exams
Entrance Exams
Passing a pointer to the structure avoids copying the entire structure in memory, which is especially important for large structures with array members. This improves performance significantly.
A self-referential structure contains a pointer to its own type. This is the fundamental building block for creating linked lists, trees, and other dynamic data structures.
In structures, memory is allocated for each member independently. In unions, all members share the same memory location, so total memory allocated equals the size of the largest member.
Self-referential structures contain pointers to their own type, enabling dynamic data structures like linked lists and trees.
A self-referential structure with a single pointer member is the fundamental building block of a singly linked list.
typedef creates an alias, allowing you to use the structure name directly without using 'struct' keyword.
Both (*ptr).member and ptr->member are valid. Option B uses explicit dereferencing, while the arrow operator is syntactic sugar for this.
In a union, all members occupy the same memory space, while struct members have individual memory locations.
struct Data {
int a;
char b;
};
struct Data d = {10, 'A'};
Which method of initialization is used here?
Values are assigned in the order they appear in the structure definition, which is positional initialization.
A structure allows grouping of different data types. Padding may be added by the compiler for alignment.