Dynamic Memory Allocation + Pointers
Pointers - stores address of variable int *a = &b --> a is pointer pointing to address of b --> use *a to access b int &a = b --> a is alias to b --> both a and b have same address => use a to access b arr [ 3 ] = { 5 , 10 , 20 }; *arr --> 5 but *(arr + 1) --> 10 for 2-D array -> *(*arr + 1) --> arr[0][1] and *(*(arr + 1)) --> arr[1][0] Dereferencing - Retrieve data contained at memory location where the pointer points void pointers give great flexibility as can point to any data type. But to dereference => first transform it into some other data type Memory Leak - When user forgets to deallocate memory for future use m = malloc ( 5 ); m = NULL ; → allocate 5-byte memory from heap and store address in pointer m → but now program has lost this address bcz no pointer points to it anymore → this memory can't be accessed or freed for lifetime of program Dangling Pointer - When delete pt...