Question: I have a question which involves calling a function with 2 parameters of a pointer to a pointer

```
int main(void)
{ ...
int *ptrp = &p, *ptrq = &q;
int **ppp = &ptrp, **ppq  = &ptrq;
swap_ptr(ppp,ppq);/* &ptrp, &ptrq passed */ 
/* to swap_ptr() */
return 0;
}

void swap_ptr(int **ptrA,int **ptrB)...

```

We have to swap the values of ptrp and ptrq, so does that mean in the swap\_ptr function I just use \*ptrA and \*ptrB to swap them or is it some other pointer statement?

Thanks

Answer: 
Yes, `*ptrA` would refer to the variable `ptrp` in `main` and `*ptrA` would refer to `ptrq`. Swap these two values as you would for any other type and `ptrp` will now point to `q` and `ptrq` to `p`.

Since this sounds like it might be homework I'll let you come up with the three lines of code.
\*ptrp refers to the value that the pointer is pointing to.
ptrp refers to the value of the pointer (the memory location)

swap\_ptr could simply store one of the values in a tmp var and then swap the values.