Hello,

I am working on pointer to pointers. I know that a pointer is a variable that has a value that is an address. But I am getting confused with pointers to pointers in C.

I have a program that I have modified to try and understand this concept.

Is the parameter **source the address of the actual pointer?

What is the real purpose of having pointers to pointers? I have seen them alot by looking at source code, but not completely sure why someone would want to use one. What would an alternative be in using pointer to pointers in C programming?

Many thanks,


Code:
void find_integer(int **source)
{
    // int *pint = &INTEGER;

	printf("***************************\n");

    printf("*source = %d\n", *source);
	printf("**source = %d\n", **source);
	printf("Address of &*source %p\n", &*source);
	printf("Address of &source %p\n", &source);
	printf("Value pointed to *source %d\n", *source);
	//printf("Value pointed to **source %d\n", **source);
	printf("*************************\n\n");
    
	*source = &INTEGER;

    printf("*source = %p\n", *source);
    printf("**source = %d\n", **source);
}

int main()
{
    int *pint = &INTEGER;
    double *preal = NULL;
    int a = 3, b = 5;

	printf("Address of Integer %p\n", &INTEGER);
	printf("Address of pint %p\n\n", &pint);

    find_integer(&pint);
    return 0;
}