Difference Between ‘int *’ and ‘int **’ in C

Properties

int *a;

int **a;

Pointer Type Points to an integer variable. Points to a pointer to an integer.
Usage Directly points to a value. Points to a pointer that points to value.
Declaration int *a; int **a;
Initialization int *a = &x; where x is an integer variable. int **a = p; where p is a pointer to an integer.
Dereferencing Access the value using *a. Access the value using the **a.
Typical Use Cases Commonly used for single values, arrays, and dynamic memory allocation. Used when working with the multi-dimensional arrays, dynamic memory allocation, or functions that modify pointers.
Example int x = 10; int *a = x; int x = 10; int *px = x; int **a = px;


Difference between int *a and int **a in C

In C, the declarations int *a and int **a represent two different concepts related to pointers. Pointers play a fundamental role in memory management and data manipulation in C programming so it is important to have a clear understanding of them.

Similar Reads

What does int * means?

This declares a pointer to an integer. It means that the variable a can store the memory address of the integer variable....

Understanding ‘int **’

...

Difference Between ‘int *’ and ‘int **’ in C

This declares a pointer to a pointer to an integer. It means that the variable a can store the memory address of the pointer to an integer variable....