sizeof void pointer

前端 未结 5 633
无人及你
无人及你 2020-12-24 07:24

why is sizeof void pointer 2 ?

5条回答
  •  孤独总比滥情好
    2020-12-24 08:10

    Size of a Pointer is equal to the size of an Integer . It can be 2 bytes in a 16bit compiler and 4 bytes in 32 bit compiler and 8 in 64 bit compiler.

    void *ptr, int *ptr and char *ptr will give you same size but if you do ptr++ , the corresponding pointer will jump according to there data types. ie 1 position in void and char case. Similarly 4 positions in int case.

提交回复
热议问题