

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Array and Structure
In this post, we will understand the difference between array and structure.
Array
It refers to a collection that consists of elements of homogenous/same data type.
It uses subscripts/ ‘[ ]’ (square brackets) to access the elements.
It is a pointer that points to the first element of the collection.
The array objects can’t be instantiated.
The size of array is fixed based on the number of elements in the array.
This size is the product of number of elements and size of every element.
Bit field is not possible in an array.
It is considered as a primitive data type.
Traversing through and searching for elements in an array is quick and easy.
It can be declared using the ‘[ ]’.
Array size is fixed and is basically the number of elements multiplied by the size of an element.
It is stored in contiguous memory locations.
Example
data_type array_name[size];
Structure
It is a collection that consists of elements of heterogenous/dissimilar data types.
It uses the ‘.’ (dot operator) to access the elements.
It isn’t a pointer.
It can be instantiated.
The size is not fixed.
This is because the elements in a structure can be of different data types and sizes.
Bit field is possible to create in a structure.
It can be declared using the ‘struct’ keyword.
It is a user-defined datatype.
Traversing and searching through a structure is slow and complex.
They may or may not be stored in a contiguous memory location.
Example
struct sruct_name { data_type1 ele1; data_type2 ele2; };
- Related Questions & Answers
- Difference between Structure and Array in C
- Difference Between Structure and Union
- Difference Between Structure and Class
- Difference between Structure and Union in C
- Difference between data type and data structure
- Difference between Class and Structure in C#
- Difference between Structure and Union in C Program
- Difference Between Array and Pointer
- Explain the Difference Between Linear and Non-linear Data Structure
- Difference Between Array and Linked List
- Difference Between Character Array and String
- Difference between pointer and array in C
- Difference between Array and Pointers in C.
- Difference between Work area, global structure and internal table in SAP ABAP
- Difference between String and Character array in Java.