Table of content
Limitations of Array in C Programming :
We know What is an array in C Programming. Array is very useful which stores multiple data under single name with same data type. Following are some listed limitations of Array in C Programming.
A. Static Data
- Array is Static data Structure
- Memory Allocated during Compile time.
- Once Memory is allocated at Compile Time it Cannot be Changed during Run-time
B. Can hold data belonging to same Data types
- Elements belonging to different data types cannot be stored in array because array data structure can hold data belonging to same data type.
- Example : Character and Integer values can be stored inside separate array but cannot be stored in single array
C. Inserting data in Array is Difficult
- Inserting element is very difficult because before inserting element in an array we have to create empty space by shifting other elements one position ahead.
- This operation is faster if the array size is smaller, but same operation will be more and more time consuming and non-efficient in case of array with large size.
D. Deletion Operation is difficult
- Deletion is not easy because the elements are stored in contiguous memory location.
- Like insertion operation , we have to delete element from the array and after deletion empty space will be created and thus we need to fill the space by moving elements up in the array.
E. Bound Checking
- If we specify the size of array as ‘N’ then we can access elements upto ‘N-1′ but in C if we try to access elements after ‘N-1′ i.e Nth element or N+1th element then we does not get any error message.
- Process of Checking the extreme limit of array is called Bound Checking and C does not perform Bound Checking.
- If the array range exceeds then we will get garbage value as result.
F. Shortage of Memory
- Array is Static data structure. Memory can be allocated at compile time only Thus if after executing program we need more space for storing additional information then we cannot allocate additional space at run time.
- Shortage of Memory , if we don’t know the size of memory in advance
G. Wastage of Memory
- Wastage of Memory , if array of large size is defined
Here are more some recommended readings on limitations on array.