A pointer is simply a variable that holds a value, that value is a memory address.
A pointer to a pointer is also simply a variable that holds a value. That value is the memory address of a pointer.
You use a pointer to a pointer when you want to change the value of a pointer.
//Not a very useful example, but shows what I mean...
void getOffsetBy3Pointer(const char *pInput, char **pOutput)
{
*pOutput = pInput + 3;
}
And you call this function like so:
const char *p = "hi you";
char *pYou;
getOffsetBy3Pointer(p, &pYou);
assert(!stricmp(pYou, "you"));
Now consider what would happen if we tried to implement this function with a single pointer.
//Note: This is completely wrong
void BadGetOffsetBy3Pointer(const char *pInput, char *pOutput)
{
//*pOutput refers to the first actual char element that pOutput points to.
pOutput = pInput + 3;
//pOutput now points to pInput + 3, but the variable we passed in remains distinct.
}
And you call this function like so:
const char *p = "hi you";
char *pYou = NULL;
BadGetOffsetBy3Pointer(p, pYou);
assert(pYou == NULL);
Note in the BadGetOffsetBy3Pointer, we could have changed some of the characters, but we couldn't change what pYou points to.