Advantages and Disadvantages of Array in C Programming
It is better and convenient way of storing the data of same datatype with same size.
It allows us to store known number of elements in it.
It allocates memory in contiguous memory locations for its elements. It does not allocate any extra space/ memory for its elements. Hence there is no memory overflow or shortage of memory in arrays.
Iterating the arrays using their index is faster compared to any other methods like linked list etc.
It allows to store the elements in any dimensional array – supports multidimensional array.
It allows us to enter only fixed number of elements into it. We cannot alter the size of the array once array is declared. Hence if we need to insert more number of records than declared then it is not possible. We should know array size at the compile time itself.
Inserting and deleting the records from the array would be costly since we add / delete the elements from the array, we need to manage memory space too.
It does not verify the indexes while compiling the array. In case there is any indexes pointed which is more than the dimension specified, then we will get run time errors rather than identifying them at compile time.
Important things to know about Arrays
Array indexes always begin with 0. Hence when we say array of size 10, array has elements from index 0 to 9. If we specify or use array as intArr, intArr, intArr, the C compiler will not show any error, but we will get run time errors while executing the program.
Arrays are supported by primitive datatypes, non-primitive types like structures, unions, pointers etc