Please find the code snippet as shown below:
#include <stdio.h>
int My_func(int **);
int main()
{
int a =5;
int *p = &a;
My_Func(&p);
printf("The val of *p is %d\n",*p);
}
void My_Func(int **p)
{
int val = 100;
int *Ptr = &val;
*p = Ptr;
}
How does using a double pointer as an argument in my_Func function and also making a change of value, both reflect the same in the main function? If we use a single pointer in My_Func, why does that not change the value in main? Please explain this for me with examples if possible.