H Dynamic Memory Allocation Pointers to pointers are very useful in dynamic memory allocation especially when dealing with twodimensional arrays. int rows cols int arr int mallocrows sizeofint Allocate row pointer array for int i i rows i arri int malloccols sizeofint Allocate memory for each row for int i i rows i for int j j cols j arrij i j Initialize twodimensional array.
Print twodimensional array
for int i i rows i for int j j cols j printfd arrij printfn Release memory for int i i rows i freearri freearr In this example arr is a pointer to a pointer which Rich People Number is used to dynamically allocate and operate a twodimensional array. H Advanced application of pointers to pointers H Using pointers to pointers in functions Pointers to pointers are very useful in function.
Parameters and can be used
To modify the pointer itself. For example c Copy code void allocateMemoryint p p int mallocsizeofint if p NULL p int main int p Afghanistan Phone Number List NULL allocateMemoryp printfThe allocated memory value is dn p freep return In this example the allocateMemory function accepts a pointer to a pointer parameter and allocates memory and modifies the pointer.