what does it mean to convert int to void* or vice versa?

前端 未结 6 1100
广开言路
广开言路 2020-11-27 07:13

What does it mean to convert an integer value to a void* or viceversa from a memory point of view? My understanding is void* is an address to a blo

6条回答
  •  星月不相逢
    2020-11-27 07:24

    Both void* pointer (or any pointer for that matter) and int are, roughly speaking, numbers. They may be of different bitsize, but it is unlikely that pointer is smaller than int, so that makes the operation reversible. Of course, it's illegal and you should never dereference the pointer that has no valid location to point to.

提交回复
热议问题