How to declare a double-pointer in C?
a) int *ptr;
b) int **ptr;
c) int &ptr;
d) int **ptr[2];
Answer:
b) int **ptr;
Explanation:
A double-pointer (or pointer to a pointer) in C is declared as int **ptr;
. This declaration means that ptr
is a pointer to another pointer, which in turn points to an integer. Double-pointers are often used in dynamic memory allocation and for passing pointers to functions that need to modify the original pointer.
Understanding how to declare and use double-pointers is essential for advanced memory management and complex data structures in C programming.