The problem is with this line.
*x[i] = 0;
Add parenthesis to the pointer dereference.
(*x)[i] = 0;
This is because x[i] actually means *(x+i). That is, add i to pointer x to get a new pointer and get the value of that memory location.
Now remember that x is a pointer to a pointer. *x[i]
can be more readily be read as **(x+i)
when actually you want *((*x)+i)
.
It might take a bit of thought to get your head around but pointers are easy once you get the hang of it.