I have a function that takes a char **
; it uses it internally for maintaining context between successive calls.
What is the difference between defining char **x
and passing x
to it, and defining char *x
and passing &x
?
For context: I tried to implement the example at strtok
man page on my own before reading the source code. And I got segfaults. Then after attempts I looked at the source.
The problem was that I defined char **x
and passed x
as the **saveptr
argument, but changing the definition to char *x
and the passing to &x
solved the problem.
What is the problem exactly?