Pointer does not increment, if incremented in other function

This question already has an answer here:

  • What's the difference between passing by reference vs. passing by value? 18 answers

  • 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.

    链接地址: http://www.djcxy.com/p/20624.html

    上一篇: PHP中的数组是通过值还是通过引用传递的?

    下一篇: 如果在其他函数中增加,指针不会增加