Recall & Review
beginner
What is a pointer to a pointer in C?
A pointer to a pointer is a variable that stores the address of another pointer variable. It allows indirect access to the value pointed to by the first pointer.
Click to reveal answer
beginner
How do you declare a pointer to a pointer for an int variable?
You declare it as
int **ptr; where ptr is a pointer to a pointer to an int.Click to reveal answer
intermediate
Given
int x = 10; and int *p = &x;, how do you declare and assign a pointer to pointer pp?Declare
int **pp = &p;. Now pp points to p, which points to x.Click to reveal answer
intermediate
How do you access the value of
x using the pointer to pointer pp?Use
**pp to get the value of x. The first * gets the pointer p, the second * gets the value x.Click to reveal answer
advanced
Why are pointers to pointers useful in C programming?
They are useful for dynamic memory management, passing pointers by reference to functions, and handling multi-dimensional arrays or complex data structures.
Click to reveal answer
What does
int **pp; declare?✗ Incorrect
int **pp; means pp is a pointer to a pointer to an int.If
int x = 5; and int *p = &x;, what is the type of &p?✗ Incorrect
&p is the address of p, which is a pointer to int, so its type is int **.How do you access the value of
x using a pointer to pointer pp?✗ Incorrect
Using
**pp dereferences twice to get the value of x.Which of the following is a valid assignment for a pointer to pointer?
✗ Incorrect
pp must store the address of a pointer variable like p, so int **pp = &p; is correct.Why might you pass a pointer to pointer to a function?
✗ Incorrect
Passing a pointer to pointer lets the function change the original pointer's value (e.g., allocate memory).
Explain what a pointer to pointer is and how you declare one in C.
Think about a pointer that points to another pointer.
You got /3 concepts.
Describe how to access the value of an int variable using a pointer to pointer.
Remember each * removes one level of indirection.
You got /3 concepts.