If you have a pointer that you pass to a function, and inside the function you want to change what it points to, and have that change keep, you instead need a pointer to a pointer.
Just like you can't pass an integer, and have it keep its value change, the same goes for any other object. To make changes persist outside of the function you change them in, you need a pointer to that type. Arrays are a slightly special case, because they degrade a bit when you pass them to functions.
Code:
void foo( char s[] ); /* this is the same as... */
void foo( char *s ) /* ...this */
Arrays degrade to pointers to the type of the first element in the array. That means an array of characters, when passed to a function, degrades to a pointer to a char. You can change the contents of an array, but you cannot make the array "point" anywhere else. The same goes for passed pointers. You can change the contents of what the pointer points to, but you can't make the pointer point to something else. Unless...
Code:
void foo( char **s )
{
*s = malloc( strlen( "bar" ) + 1 );
strcpy( *s, "bar" );
}
...
char *p = "point to whatever...";
...
foo( &p ); /* ...now will end up pointing elsewhere. */
...
char array[] = "some array of stuff...";
...
foo( &array ); /* legal call... ...won't point somewhere else */
Arrays are not actually poitners, so you cannot make the array "point" somewhere else. Basically this will give you some Bad Things(TM).
Quzah.