p holds the address of the first character in the string literal, in this case "H".
p [Address of string literal] -> ["H....]
retptr is a pointer that pointer to a character pointer so when it is dereferenced, *retptr is a character pointer and is assigned the value in p ( the address of the first character of the string literal )
retptr [Address of *retptr ] ->*retptr [Address of string literal] -> ["H.....]
I should point out however ( no pun intended ) that you cannot create such a function as you would be assigning the address of a local variable which will be destroyed when the function exits ( *retptr will then point to invalid memory ). If you wish a function like this, you will need to use malloc instead:
Code:
int allocstr(char **retptr)
{
char temp[] = "Hello";
*retptr = malloc(sizeof(char)*(strlen(temp)+1));
strcpy(*retptr,temp);
return 1;
}
And what do you mean retptr = &p returns null to you? I do not see this code?