
The address of memory location num1 and num2 are passed to function and the pointers *a and *b accept those values. So, the
pointer a and b points to address of num1 and num2 respectively. When, the value of pointer are changed, the value in memory location also changed correspondingly. Hence, change made to *a and *b was reflected in num1 and num2 in main function.
This technique is known as call by reference in C programming.
C Programming Dynamic Memory Allocation
The exact size of array is unknown untill the compile time,i.e., time when a compier compiles code written in a programming language into a executable form. The size of array you have declared initially can be sometimes insufficient and sometimes more than required.
Dynamic memory allocation allows a program to obtain more memory space, while running or to release space when no space is
required.
Although, C language inherently does not has any technique to allocated memory dynamically, there are 4 library functions
under "stdlib.h" for dynamic memory allocation.
Function Use Of Function