Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Difference Between a Pointer to an Array and Array of Pointers

Pointer Vs. Array: Find the Difference Between Pointer to an Array and Array of Pointers

Both of these have a very close relationship in the C language, but there is a fundamental difference between Pointer to an Array and Array of Pointers. In this article, we will discuss the same. But let us first know a bit more about each of them individually.

What is a Pointer to an Array?

The array pointer is an alternative name to a pointer to an array. We generally make use of this pointer for accessing the various components of any given array. The pointer ptr basically focuses on the 0th component of any given array. Likewise, one can easily declare a point that is capable of pointing to a whole array- rather than only a single array component.

What is an Array of Pointers?

It refers to an array of various pointer variables, also called the pointer arrays. One can easily create separate pointer variables pointing towards different ranges of values. And we can also create a single integer array of pointers pointing towards all the available values.

Difference Between a Pointer to an Array and Array of Pointers

Here is a list of the differences present between Pointer to an Array and Array of Pointers.

Parameters Pointer to an Array Array of Pointers
Uses and Purposes A user creates a pointer for storing the address of any given array. A user creates an array of pointers that basically acts as an array of multiple pointer variables.
Alternative Names It is alternatively known as an array pointer. These are alternatively known as pointer arrays.
Allocation One can allocate these during the run time. One can allocate these during the compile time.
Initialization at Definition You cannot initialize a pointer to the definition. You can easily initialize an array at the definition level.
Nature It is dynamic in nature. It is static in nature.
Resizing One can easily resize the allocated memory of a pointer later at any given time. Once we declare the size of an array, we cannot resize it any time we want according to our requirements.
Type of Storage A typical pointer variable is capable of storing only a single variable within. The size of any given array decides the total number of variables that it can store within.

Keep learning and stay tuned to BYJU’S to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2024, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cutoff, GATE Previous Year Question Paper, and more.

Also Explore,

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*