Key Differences Between Array and Structure
Key Differences Between Array and Structure
types.
1. Where an Array is a collection of variables of the similar data type. On the other hand, Structure is
a collection of variables of dissimilar data types.
2. Variable of an array are stored in a contiguous memory location whereas, the variables in a
structure may or may not be stored in a contiguous memory location.
3. If you want to access any variable in an array you have to access it using its index number which
shows its position in that array. If you want to access a variable in a structure then you have to
access it using structure name followed by a dot followed by a variable name.
4. An operator used in Array is square bracket “[ ]”, it is used while Array declaration and also while
accessing an array variable. An operator used in the structure to access the structure variable is a
dot operator.
5. An array name is a pointer, as the name of array points to the address of a first variable in that
array. On the other hand, structure name does not point to its first element so a structure name is
not a pointer.
6. We cannot instantiate an array whereas, we can instantiate a structure.
7. All elements in an array have the same size because all elements are of the same datatype whereas,
the structure contains elements of dissimilar datatype hence, and all elements are of different size.
8. Bit-field cannot be defined in an array whereas, the structure allows defining bit field in it.
9. Declaring array does not require any keyword. Declaring a structure requires a keyword struct.
10. An array is not a user defined data type whereas structure is a user-defined datatype.
11. An array can be accessed faster as compared to a structure.
12. Searching an element in an array is faster as compared to a structure.