Character pointers and integer pointers (++)

前端 未结 10 1347
终归单人心
终归单人心 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:25

    A char is 1 byte, an int is (typically) 4 bytes. When you increment a pointer, you increment by the size of the data being pointed to. So, when you increment a char*, you increment by 1 byte, but when you increment an int*, you increment 4 bytes.

提交回复
热议问题