#include <stdio.h>
#if 0
int fun(int *p)
{
int n=10;
int *q = &n; // char to pointer is different
p = q; // pointer to pointer so the q value can be copied
printf("%d",*p); // the pointer value cannot be passed to the main
/*
int q = 10;
p = q; // pointer to integer so p cannot take q value
printf("%d",*p);
*/
}
int main()
{
int r = 20;
int *p = &r;
fun(p);
printf("%d", *p);
return 0;
}
#endif
void fun(int **pptr)
{
static int q = 10;// or no static its ok
*pptr = &q;
}
int main()
{
int r = 20;
int *p = &r;
fun(&p);
printf("%d", *p);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: