Array | Structure |
---|---|
Array is collection of elements having same datatype. | Structure is collection of elements having different datatypes. |
Array uses subscript for accessing elements.
example : a[i] here, ith element of array is accessed. |
Structure uses dot (.)operator for accessing element.
example : b.name here,name element of structure b accessed. |
The first element of array is numbered from zero. | The first element of structure is numbered from one. |
Array element stored at adjucent memory location. | Structure element at contigeous memory location. |
syntax/example : int a[5]; |
syntax/example :struct num { int a; }; struct num b[5]; |