How do pointer to pointers work in C?

前端 未结 14 1254
渐次进展
渐次进展 2020-11-22 02:03

How do pointers to pointers work in C? When would you use them?

14条回答
  •  渐次进展
    2020-11-22 03:07

    it's a pointer to the pointer's address value. (that's terrible I know)

    basically, it lets you pass a pointer to the value of the address of another pointer, so you can modify where another pointer is pointing from a sub function, like:

    void changeptr(int** pp)
    {
      *pp=&someval;
    }
    

提交回复
热议问题