In the below program
#include <stdio.h>
void fun1(char **p1)
{
char ch1[] = "abc";
*p1 = ch1;
}
void fun2(char **p2)
{
char ch2[] = "def";
*p2 = ch2;
}
int main()
{
char *p1 = NULL;
char *p2 = NULL;
fun1(&p1);
fun2(&p2);
printf("string %s %s", p1, p2);
return 0;
}
This gives me output as
string def def
I see both p1 and p2 are having same addresses. How is this working internally?