Uploaded November 2026 | Updated December 2026, 3 hours ago
Learn how to Pass Double Pointers to Functions in C programming and understand how to modify a Pointer Variable inside a function using a Pointer to Pointer.
In this beginner-friendly C programming tutorial, we explore how functions can accept Pointer to Pointer parameters and use Double Pointers to access and change pointer values.
We begin by reviewing the Pointer to Pointer concept discussed in the previous tutorials.
Next, we create two Integer Variables named first and second and initialize them with the values 10 and 20.
We also create a Pointer to int named pti and initialize it with nullptr.
For example:
int first = 10;
int second = 20;
int *pti = nullptr;
After that, we use an if-else statement to check whether pti contains nullptr before dereferencing it.
We explain why a Null Pointer must not be dereferenced and demonstrate how to safely access the pointed-to Integer Object after assigning a valid pointer value.
Next, we make pti point to the first Integer Variable.
For example:
pti = &first;
We use printf() and the %d Format Specifier to display the value of the object pointed to by pti.
The output is 10.
After that, we explore an important question: How can we change the value of a Pointer Variable inside another function?
Instead of directly assigning &second to pti inside main(), we create a separate function named change_pointer().
This function accepts a Pointer to Pointer to int as its parameter.
For example:
void change_pointer(int **ppti)
{
*ppti = nullptr;
}
We explain how the Address-of Operator (&) is used to pass the address of the Pointer Variable pti to the function.
For example:
change_pointer(&pti);
Inside change_pointer(), we dereference ppti once to access the original Pointer Variable pti.
By assigning nullptr to *ppti, we modify the pointer value stored in pti, even though pti is defined inside main().
Next, we verify that pti now contains nullptr using the if-else statement.
After that, we modify the change_pointer() function to accept another argument.
The second parameter is a Pointer to int named target_pti.
We update the function so that it changes the original Pointer Variable to point to a different Integer Object.
For example:
void change_pointer(int **ppti, int *target_pti)
{
*ppti = target_pti;
}
Next, we call the function from main().
change_pointer(&pti, &second);
We explain how the first argument provides the address of the Pointer Variable pti and the second argument provides the address of the Integer Variable second.
Inside the function, *ppti accesses the original Pointer Variable and assigns it the pointer value stored in target_pti.
As a result, pti now points to second instead of first.
Finally, we dereference pti and display the value 20, confirming that the Pointer Variable was successfully modified inside another function.
This tutorial helps you understand Passing Double Pointers to Functions, Pointer to Pointer Parameters, Pointer Dereferencing, Modifying Pointer Variables, Address-of Operator, nullptr, and Pointer Reassignment in C programming.
Our Website
LearningLad.com
Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial
Learn how to Pass Double Pointers to Functions in C programming and understand how to modify a Pointer Variable inside a function using a Pointer to Pointer.
In this beginner-friendly C programming tutorial, we explore how functions can accept Pointer to Pointer parameters and use Double Pointers to access and change pointer values.
We begin by reviewing the Pointer to Pointer concept discussed in the previous tutorials.
Next, we create two Integer Variables named first and second and initialize them with the values 10 and 20.
We also create a Pointer to int named pti and initialize it with nullptr.
For example:
int first = 10;
int second = 20;
int *pti = nullptr;
After that, we use an if-else statement to check whether pti contains nullptr before dereferencing it.
We explain why a Null Pointer must not be dereferenced and demonstrate how to safely access the pointed-to Integer Object after assigning a valid pointer value.
Next, we make pti point to the first Integer Variable.
For example:
pti = &first;
We use printf() and the %d Format Specifier to display the value of the object pointed to by pti.
The output is 10.
After that, we explore an important question: How can we change the value of a Pointer Variable inside another function?
Instead of directly assigning &second to pti inside main(), we create a separate function named change_pointer().
This function accepts a Pointer to Pointer to int as its parameter.
For example:
void change_pointer(int **ppti)
{
*ppti = nullptr;
}
We explain how the Address-of Operator (&) is used to pass the address of the Pointer Variable pti to the function.
For example:
change_pointer(&pti);
Inside change_pointer(), we dereference ppti once to access the original Pointer Variable pti.
By assigning nullptr to *ppti, we modify the pointer value stored in pti, even though pti is defined inside main().
Next, we verify that pti now contains nullptr using the if-else statement.
After that, we modify the change_pointer() function to accept another argument.
The second parameter is a Pointer to int named target_pti.
We update the function so that it changes the original Pointer Variable to point to a different Integer Object.
For example:
void change_pointer(int **ppti, int *target_pti)
{
*ppti = target_pti;
}
Next, we call the function from main().
change_pointer(&pti, &second);
We explain how the first argument provides the address of the Pointer Variable pti and the second argument provides the address of the Integer Variable second.
Inside the function, *ppti accesses the original Pointer Variable and assigns it the pointer value stored in target_pti.
As a result, pti now points to second instead of first.
Finally, we dereference pti and display the value 20, confirming that the Pointer Variable was successfully modified inside another function.
This tutorial helps you understand Passing Double Pointers to Functions, Pointer to Pointer Parameters, Pointer Dereferencing, Modifying Pointer Variables, Address-of Operator, nullptr, and Pointer Reassignment in C programming.
Our Website
LearningLad.com
Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial






![Pointer Arithmetic in C Explained | Addition, Subtraction & Array Indexing
Learn how Pointer Arithmetic works in C programming and understand how to use Addition, Subtraction, Increment, and Decrement operations with Pointers.
In this beginner-friendly tutorial, we first introduce Pointer Arithmetic and discuss the arithmetic operations that can be performed on pointers in C.
We explain how adding or subtracting an integer from a pointer generates a pointer value referring to a different element within an array.
Using an Integer Array containing 10, 20, 30, and 40, we demonstrate how Pointer Arithmetic works with Array Elements and Memory Addresses.
Next, we explain why Pointer Arithmetic depends on the type of object a pointer points to.
For example, when we add 1 to a Pointer to int, the resulting pointer refers to the next integer element, not simply the next byte in memory.
We compare Pointer Arithmetic with int * and char * pointers to demonstrate how the pointer type determines the number of bytes between consecutive elements.
After that, we explore Pointer Addition and Subtraction using expressions such as:
1. ptr + 1
2. ptr + 2
3. ptr - 1
4. ptr + 0
We explain how these expressions generate pointer values relative to the element currently pointed to by ptr.
Next, we combine Pointer Arithmetic with Pointer Dereferencing to access and modify Array Elements.
Using expressions such as *(ptr + 1) and *(ptr + 3), we demonstrate how to read and modify values stored in an Integer Array.
We then explore the relationship between Array Indexing and Pointer Arithmetic.
We compare the following expressions:
1. numbers[1]
2. *(numbers + 1)
3. ptr[1]
4. *(ptr + 1)
We demonstrate how these expressions access the same Array Element when ptr points to the first element of numbers.
Next, we explain why Array Indexing starts at zero and how the Array Subscript Operator [] works using Pointer Arithmetic.
We also explore an interesting feature of C: expressions such as 1[ptr] and 1[numbers] are valid because Pointer Addition allows both ptr + 1 and 1 + ptr.
However, we explain why Subtraction is different and why an expression such as 1 - ptr is not valid.
After that, we discuss the difference between generating a new Pointer Value and modifying the value stored in a Pointer Variable.
We demonstrate how ptr + 1 produces a pointer value without changing ptr, while ptr = ptr + 1 updates the pointer variable.
Next, we explain why standard C does not allow Pointer Arithmetic directly on void * pointers, since void does not provide a complete object type for determining element sizes.
Finally, we explore Pointer Increment and Decrement operations using ptr++, ++ptr, ptr , and ptr.
We explain how these operations update the pointer variable so that it refers to the next or previous Array Element.
This tutorial helps you understand Pointer Arithmetic, Pointer Addition, Pointer Subtraction, Array Indexing, Pointer Dereferencing, Pointer Increment and Decrement, and Memory Addresses in C programming.
Our Website
https://www.LearningLad.com
Social Media
Facebook https://www.facebook.com/LearningLad
Twitter https://www.twitter.com/LearningLadEdu
Instagram https://www.instagram.com/LearningLadOfficial Pointer Arithmetic in C Explained | Addition, Subtraction & Array Indexing](https://i.ytimg.com/vi/SVuWLkJTeCY/mqdefault.jpg)



