Difference between Structure and Array in C


In C both Structure and Array are used as container for data types i.e in both structure and array we can store data and also can perform different operations over them.

On the basis of internal implementation following are some basic differences between both.

Sr. No.KeyStructureArray
1DefinitionStructure can be defined as a data structure used as container which can hold variables of different types.On other hand Array is a type of data structure used as container which can hold variables of same type and do not support multiple data type variables.
2Memory AllocationMemory allocation for input data in structure does not necessary to be in consecutive memory location.While in case of array the input data stored in contiguous memory allocation which implies that array stores data in such memory model where it assigns consecutive memory blocks (that is, memory blocks having consecutive addresses).
3AccessibilityIn order to access the element in Structure we require to have the name of that element i.e it is mandatory to have element name for its retrieval from Structure.On other hand in case of Array we can access the element by index.
4PointerStructure do not have concept of Pointer internally.On other hand in case of Array it internally implements Pointer which always points to the first element of Array.
5InstantiationStructure object can be created after declaration later in the program.On other hand in case of Array we can't create its object after declaration.
6DataTypeStructure supports multiple data-type variables as input.On other hand in case of Array we can't have different data-type variable as input as it only supports same type data variables.
7PerformanceStructure due to use defined data type become slow in performance as access and searching of element is slower in Structure as compare to Array.On other hand in case of Array access and searching of element is faster and hence better in performance.

Updated on: 25-Feb-2020

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements