Well a pointer is also data, so it's useful everywhere where having a pointer to data is useful. One usecase I find kinda neat is for linked list algorithms. See https://github.com/mkirchner/linked-list-good-taste Answer from aocregacc on reddit.com
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ c-pointer-to-pointer-double-pointer
C - Pointer to Pointer (Double Pointer) - GeeksforGeeks
Double Pointers are not the only multilevel pointers supported by the C language. What if we want to change the value of a double pointer? In this case, we can use a triple pointer, which will be a pointer to a pointer to a pointer i.e, int ***t_ptr.
Published ย  October 25, 2025
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ what's the use of pointers-to-pointers?
r/C_Programming on Reddit: What's the use of pointers-to-pointers?
May 11, 2023 -

I already get the idea of plain old pointers to data. All a pointer is is a memory address where some data lives. The plain old pointers are generally used to iterate through things like arrays and tree nodes and to access data on the heap. But where are pointers-to-pointers actually useful (or triple pointers, etc.)? The only places I can think of where they are useful are for multidimentional arrays and navigating through lists of malloc'ed objects. Are there any other use cases where just a regular old pointer wouldn't be enough?

Discussions

How do pointer-to-pointers work in C? (and when might you use them?) - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... No not homework.... just wanted to know..coz i see it a lot when i read C code. ... A pointer to pointer is not a special case of something, so I don't understand what you don't understand about ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Initialize a double pointer to a struct inside another struct?
ms1 is allocated on init's stack, so it ceases to exist after init returns as the other comment mentions, the arrow operator is for deferencing pointers, you only need the dot operator for ms1 More on reddit.com
๐ŸŒ r/C_Programming
2
7
March 5, 2021
Is casting a pointer to size_t and then back to a pointer valid or will this cause undefined behavior?
A pointer may be converted to an integer, and an integer may be converted to a pointer. That alone doesn't mean much however. If the pointer type is specifically void * and the integer type is intptr_t or uintptr_t, then this round-trip is guaranteed to result in a pointer that compares equal to the original pointer. The C Standard doesn't say that the resulting pointer can be used for anything more than a comparison, and it also doesn't require a round-trip through intptr_t or uintptr_t to be permitted even for other kinds of object pointer, such as int *. However it would have to be a particular obtuse implementation for it to do something weird here. One would expect any integer type that is "sufficiently wide" to permit round-trips too. C does not guarantee this, except for the sole case of converting a null pointer to an integer and back again. However it is commonly assumed to hold, and a lot of software is written with the assumption in mind. The Linux kernel assumes that long is the same size as a pointer and that a round-trip (certainly from any object pointer type, and probably from a function pointer type too) through long is safe. size_t, however, may not be wide enough to represent a pointer-converted-to-an-integer at all. The pointer you get back with a round-trip through size_t may be completely invalid. Everything regarding conversions here is implementation-defined behaviour, so it should be possible to check your implementation's documentation for details. If it says that a particular sequence of operations results in an invalid pointer, use of that pointer would have undefined behaviour. More on reddit.com
๐ŸŒ r/C_Programming
3
4
November 15, 2021
A struct instance containing a pointer to itself? : C_Programming
Want to join? Log in or sign up in seconds. ... For people who struggle like me with pointers and strings. ... Post a comment! More on old.reddit.com
๐ŸŒ r/C_Programming
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ cprogramming โ€บ c_pointer_to_pointer.htm
Pointer to Pointer (Double Pointer) in C
When we define a "pointer to a ... is similar to the declaration of a pointer, the only difference is that you need to use an additional asterisk (*) before the pointer variable name....
Top answer
1 of 14
413

Let's assume an 8 bit computer with 8 bit addresses (and thus only 256 bytes of memory). This is part of that memory (the numbers at the top are the addresses):

  54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69
+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|    | 58 |    |    | 63 |    | 55 |    |    | h  | e  | l  | l  | o  | \0 |    |
+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+

What you can see here, is that at address 63 the string "hello" starts. So in this case, if this is the only occurrence of "hello" in memory then,

const char *c = "hello";

... defines c to be a pointer to the (read-only) string "hello", and thus contains the value 63. c must itself be stored somewhere: in the example above at location 58. Of course we can not only point to characters, but also to other pointers. E.g.:

const char **cp = &c;

Now cp points to c, that is, it contains the address of c (which is 58). We can go even further. Consider:

const char ***cpp = &cp;

Now cpp stores the address of cp. So it has value 55 (based on the example above), and you guessed it: it is itself stored at address 60.


As to why one uses pointers to pointers:

  • The name of an array usually yields the address of its first element. So if the array contains elements of type t, a reference to the array has type t *. Now consider an array of arrays of type t: naturally a reference to this 2D array will have type (t *)* = t **, and is hence a pointer to a pointer.
  • Even though an array of strings sounds one-dimensional, it is in fact two-dimensional, since strings are character arrays. Hence: char **.
  • A function f will need to accept an argument of type t ** if it is to alter a variable of type t *.
  • Many other reasons that are too numerous to list here.
2 of 14
55

How do pointers to pointers work in C?

First a pointer is a variable, like any other variable, but that holds the address of a variable.

A pointer to a pointer is a variable, like any other variable, but that holds the address of a variable. That variable just happens to be a pointer.

When would you use them?

You can use them when you need to return a pointer to some memory on the heap, but not using the return value.

Example:

int getValueOf5(int *p)
{
  *p = 5;
  return 1;//success
}

int get1024HeapMemory(int **p)
{
  *p = malloc(1024);
  if(*p == 0)
    return -1;//error
  else 
    return 0;//success
}

And you call it like this:

int x;
getValueOf5(&x);//I want to fill the int varaible, so I pass it's address in
//At this point x holds 5

int *p;    
get1024HeapMemory(&p);//I want to fill the int* variable, so I pass it's address in
//At this point p holds a memory address where 1024 bytes of memory is allocated on the heap

There are other uses too, like the main() argument of every C program has a pointer to a pointer for argv, where each element holds an array of chars that are the command line options. You must be careful though when you use pointers of pointers to point to 2 dimensional arrays, it's better to use a pointer to a 2 dimensional array instead.

Why it's dangerous?

void test()
{
  double **a;
  int i1 = sizeof(a[0]);//i1 == 4 == sizeof(double*)

  double matrix[ROWS][COLUMNS];
  int i2 = sizeof(matrix[0]);//i2 == 240 == COLUMNS * sizeof(double)
}

Here is an example of a pointer to a 2 dimensional array done properly:

int (*myPointerTo2DimArray)[ROWS][COLUMNS]

You can't use a pointer to a 2 dimensional array though if you want to support a variable number of elements for the ROWS and COLUMNS. But when you know before hand you would use a 2 dimensional array.

๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_pointer_to_pointer.php
C Pointer to Pointer (Double Pointer)
This is called a pointer to pointer (or "double pointer"). It might sound confusing at first, but it's just one more level of indirection: a pointer that stores the address of another pointer.
๐ŸŒ
Stanford CS Ed Library
cslibrary.stanford.edu โ€บ 106
Pointer Basics
For the basic pointer/pointee rules covered here, the terms are effectively equivalent. The above drawing shows a pointer named x pointing to a pointee which is storing the value 42. A pointer is usually drawn as a box, and the reference it stores is drawn as an arrow starting in the box and leading to its pointee.
๐ŸŒ
Quora
quora.com โ€บ What-is-pointer-to-pointer-in-C-2
What is pointer to pointer in C? - Quora
Answer (1 of 2): Suppose there is an integer variable: int a = 10; and a pointer variable p having the address of a: int *p = &a; But as you can see, pointer p is also variable storing the hexadecimal digits depicting the location of variable a in memory. Hence pointer p also must be residing...
Find elsewhere
๐ŸŒ
NxtWave
ccbp.in โ€บ blog โ€บ articles โ€บ pointer-to-pointer-in-c
Understanding Pointer to Pointer in C(Double Pointer)
Learn how pointer to pointer in C works, its usage, and how it helps manage dynamic memory and complex data structures efficiently.
๐ŸŒ
LeetCode
leetcode.com โ€บ problem-list โ€บ two-pointers
Two Pointers - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
๐ŸŒ
Log2Base2
log2base2.com โ€บ C โ€บ pointer โ€บ pointer-to-pointer-in-c.html
Pointer to pointer in c with example
** declaration indicates that I am a pointer but I am not pointing to a variable rather pointing to the address of another pointer. Assigning an address to the pointer. Accessing the value stored at the pointer. ... /* * Program : Pointer to Pointer * Language : C */ #include<stdio.h> int main() { int a = 10; int *ptr = &a; //ptr references a int **dptr = &ptr; //dptr references ptr printf("Address of a = %p\n",&a); printf("ptr is pointing to the address = %p\n",ptr); printf("dptr is pointing to the address = %p\n",dptr); printf("Value of a = %d\n",a); printf("*ptr = %d\n",*ptr); printf("**dptr = %d\n",**dptr); return 0; }
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ c-pointers
Pointers in C - GeeksforGeeks
Accessing the pointer directly will just give us the address that is stored in the pointer. To get the value at the address stored in a pointer variable, we use * operator which is call dereferencing operator in C
Published ย  3 weeks ago
๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ c-pointers
C Pointers (With Examples)
And, the address of c is assigned to the pc pointer. To get the value of the thing pointed by the pointers, we use the * operator. For example: int* pc, c; c = 5; pc = &c; printf("%d", *pc); // Output: 5
๐ŸŒ
Simplilearn
simplilearn.com โ€บ home โ€บ resources โ€บ software development โ€บ pointers in c: a one-stop solution for using c pointers
Pointers in C: A One-Stop Solution for Using C Pointers
June 23, 2025 - A pointer in C is a variable pointing to the address of another variable. Explore C Pointer's โœ“ types โœ“ advantages โœ“ disadvantages, and more. Start learning!
Address ย  5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
๐ŸŒ
HowStuffWorks
computer.howstuffworks.com โ€บ tech โ€บ computer software โ€บ programming
Pointers to Pointers - The Basics of C Programming | HowStuffWorks
March 8, 2023 - The program manages the pointer ... affecting the program using p. Pointers to pointers are also frequently used in C to handle pointer parameters in functions....
๐ŸŒ
Scaler
scaler.com โ€บ topics โ€บ c โ€บ pointer-to-pointer-in-c
C โ€“ Pointer to Pointer (Double Pointer) - Scaler Topics
October 9, 2023 - A pointer to pointer in C is used to access or modify the value of a pointer variable. Learn more about double pointer in C with Scaler Topics.
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_pointers.php
C Pointers
When used in declaration (int* ptr), it creates a pointer variable. When not used in declaration, it act as a dereference operator. Good To Know: There are two ways to declare pointer variables in C:
๐ŸŒ
Dot Net Tutorials
dotnettutorials.net โ€บ home โ€บ pointer to pointer in c
Pointer to Pointer in C Language with Examples - Dot Net Tutorials
November 16, 2023 - So, when we define a pointer to a pointer, the first pointer is used to store the address of the variable, and the second pointer is used to store the address of the first pointer.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ pointers-in-c-programming
How to Use Pointers in C Programming
May 3, 2023 - For example, to print the value of the integer that p points to, we would write: ... A pointer can also point to another pointer variable. This is known as a "pointer to a pointer".
๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ c-programming โ€บ pointers
Pointers in C Language (Uses, Types, Examples)
August 29, 2025 - Learn about pointers in C, their types, and uses with examples. Understand pointer basics, operations, and memory management in C programming.
๐ŸŒ
Studytonight
studytonight.com โ€บ c โ€บ pointer-to-pointer.php
Pointer to a Pointer in C(Double Pointer)
*p2 gives us the value at an address stored by the p2 pointer. p2 stores the address of p1 pointer and value at the address of p1 is the address of variable a. Thus, *p2 prints address of a. **p2 can be read as *(*p2). Hence, it gives us the value stored at the address *p2. From above statement, you know *p2 means the address of variable a. Hence, the value at the address *p2 is 10. Thus, **p2 prints 10. ... Learn and practice coding side-by-side.