Please have a look at code below :
#include <stdio.h>
void main()
{
int a=30;
int *var=&a;
Change(&var);
printf("%d %d",*var,a);
}
int Change(int**ptr)
{
**ptr=40;
}
#include <stdio.h>
void main()
{
int a=30;
int *var=&a;
Change(var);
printf("%d %d",*var,a);
}
int Change( int *ptr)
{
*ptr=40;
}
The output from both programs is 40 40
We are passing the copy of address of var so why it is reflected in actual main function and producing output 40 40
?
Why both of these programs are producing same output?