
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 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. | Key | Structure | Array |
---|---|---|---|
1 | Definition | Structure 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. |
2 | Memory Allocation | Memory 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). |
3 | Accessibility | In 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. |
4 | Pointer | Structure 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. |
5 | Instantiation | Structure 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. |
6 | DataType | Structure 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. |
7 | Performance | Structure 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. |
Advertisements