Alternative function declaration: //Function 2
void func(char *p)
p = "Hello"; // Statement 1
char *p = NULL;
printf("Val of p:%s\n",p);
void func(char **p)
*p = "Hello"; // Statement 2
What is confusing to me is the outputs:
With the function declared as in Function 1:
With the function declared as in Function 2:
1. How come Statement 1 is valid?
2. Will address be assigned to the pointer variable p in Statement 1?
3. What is the difference b/w *p="Hello" and p="Hello"?
4. how is that by calling Function 2 instead of Function 1 it prints Hello?
Thanks in advance