0
0
Cprogramming~5 mins

Pointers to pointers in C - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AA pointer to an int
BA pointer to a pointer to an int
CAn int variable
DA pointer to a char
If int x = 5; and int *p = &x;, what is the type of &p?
Aint **
Bint &
Cint
Dint *
How do you access the value of x using a pointer to pointer pp?
A*pp
B&pp
Cpp
D**pp
Which of the following is a valid assignment for a pointer to pointer?
Aint **pp = p;
Bint **pp = &x;
Cint **pp = &p;
Dint **pp = x;
Why might you pass a pointer to pointer to a function?
ATo modify the pointer itself inside the function
BTo pass an integer value
CTo avoid using pointers
DTo declare a new variable
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.