Pointer does not increment, if incremented in other function
This question already has an answer here:
In increment(char *c)
you create a new pointer c
which is pointing to the same object p
does, but they are not the same, they are just pointing to the same thing. If you increment one, the other one stays the same.
If you want to increment the pointer p
you need a pointer to this pointer, pass it to your function and change p
instead of a local copy.
下一篇: 如果在其他函数中增加,指针不会增加