I understand basic pointers but im having trouble with pointers that are written like this int **test. so its basically a pointer to a pointer? can someone give me an example how it might be useful to do such a thing or when it would be commonly used and possibly how i would get its value.
It's very simple.
Sometimes, you may want to pass a pointer to a pointer. Pointers themselves are data and therefore take up space. The address of a pointer can be assigned to a pointer (to a pointer to data). Don't let the indirection fool you- it works the same way. You can dereference it and retrieve that pointer, and derefrence that too, to retrieve the data.
An array of pointers works in a similar way. With pointers, you usually want to read right-to-left.
1 2 3 4 5
int i; //i is an integer
int *ptr= &i; //address of i assigned to a pointer to an integer
int **pptr= &ptr; //address of ptr is assigned to a pointer to (a pointer to an integer).
**pptr=0; //i is zero
*pptr=0; //ptr is now NULL