Character pointers and integer pointers (++)

前端 未结 10 1389
终归单人心
终归单人心 2020-11-29 11:50

I have two pointers,

char *str1;
int *str2;

If I look at the size of both the pointers let’s assume

str1=4 bytes
str2=4 byt         


        
10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 12:35

    Simple, in the provided scenario:

    • char is 1 byte long
    • int (in your platform) is 4 bytes long

    The ++ operator increments the pointer by the size of the pointed type.

提交回复
热议问题