Anonymous structure
In C, an anonymous structure is a structure that is declared without a name (tag). It is typically used
to group variables together in a way that makes the members directly accessible, as if they are part
of the outer structure.
Syntax of Anonymous Structure
typedef
typedef gives a shorter name to a struct, so struct doesn't have to be written each time a
variable is declared.
Union
In C, a union is a special data type that allows storing different data types in the same memory
location. Unlike a struct, where each member has its own memory, all members of a union share
the same memory space. This means that at any given time, only one member of the union can hold
a value.
Anonymous union
An anonymous union in C is a union that doesn't have a name (like an anonymous struct). The
members of the union can be accessed directly, without needing to refer to the union by its name.
bit fields
In C, bit fields let you use only a specific number of bits for a struct member instead of the usual full
bytes. This helps save memory when only a few bits are needed, like for true/false values, or small
numbers.
Enumeration, or enum,
Enums in C
Enums (enumerations) in C provide a better way to work with fixed sets of related constants.
They replace unclear numeric values with descriptive names, improving code clarity.
Example: Days of the Week