Difference between Arrays and Structures
Array:
The array is a derived data type.
It allocates memory only for index items. Array allocates static memory and uses index/subscript to access array elements.
It allocates memory of the same files that is if we declare integer type array then it allocates 2-byte memory for each cell.
It does not contain structure within itself.
It can contain only homogeneous data types.
Array serves as a pointer to the initial element.
We can access the array by using an index number.
The elements of the whole are contiguous within the memory.
Accessing the elements of the array takes less time than structures.
Structure:
The structure is a program or user-defined data type.
It does not allocate memory till the elements of the structure are accessed. Structures allocate dynamic memory and use the dot (.) operator for accessing the member of a structure.
It assigns memory to the highest datatype.
It contains an array within itself.
It can contain only non-homogeneous data types.
The structure is not a pointer.
The elements of the structure are accessed by using the dot (.) operator with the structure reference name.
The elements of the structure cannot be contiguous with each other.
