Passing Double Pointers to Functions in C | Modify Pointer Variables Using Functions @LearningLad
Passing Double Pointers to Functions in C | Modify Pointer Variables Using Functions  @LearningLad
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
Passing Double Pointers to Functions in C | Modify Pointer Variables Using FunctionsHow to use Suffixes to Interpret Integer Constants in C Programming LanguageArray Initialization in C | Partial Initialization & Zero Initialization ExplainedHow to Create a C Programming Language Project and Run a C Program in Visua StudioEnums in C Explained | Enumeration, Enumerators & Named Integer ValuesC File Handling Tutorial : ferror feof clearerr Functions ExplainedHow to Create & Call Functions in C | Function Definition Explained for BeginnersPointer Arithmetic in C Explained | Addition, Subtraction & Array IndexingHow to Download, Install Java JDK & Set JAVA_HOME & Path Variables on Windowsconst with Double Pointers in C | Pointer to Pointer & const Combinations ExplainedC Program to Delete a File Using remove() Function | File Handling TutorialPrintf Function and Escape Sequences Explained in C Programming Language | Tutorial for beginners
LearningLad |

Passing Double Pointers to Functions in C | Modify Pointer Variables Using Functions

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER