What's the difference between void* and void**?

前端 未结 6 1551
别跟我提以往
别跟我提以往 2020-12-13 07:31

It\'s the special property that void* can also be assigned a pointer to a pointer and cast back and the original value is received.

I read this line

6条回答
  •  被撕碎了的回忆
    2020-12-13 08:10

    A void** is a pointer to a void*. A void* can be converted back and forth to any pointer type (including void**). So you can do:

    char* -> void*
    void* -> void**
    void** -> void*
    void* -> char*
    

    You can not do:

    char* -> void**
    void** -> char*
    

    so they are not the same.

提交回复
热议问题