What is Structure?
Is it 36-26-36…
No, it is something different. Array is a collection of different types, but structure is collection of different data types.
Technically speaking Structure is allocates more memory.
Struct {
Int a,
Char c,
Float d,
};
It stores 2+1+4=7 bytes in memory. But if we use union we can reduce the memory space to 4 bytes.
Union allocate memory for the largest data i.e. here float size is 4 bytes so it allocates4 bytes.
Can Structure be declared within a structure?
Structure can be declared within the structure.
Struct date {
Int day, month, year;
};
Struct history
{
Char name [25];
Struct date;
};
Structure can also be declared as array of structures.