Different Pointer Arithmetic Results when Taking Address of Array

后端 未结 5 2077
北恋
北恋 2020-12-25 10:14

Program:

#include

int main(void) {
    int x[4];
    printf(\"%p\\n\", x);
    printf(\"%p\\n\", x + 1);
    printf(\"%p\\n\", &x);
    p         


        
5条回答
  •  情歌与酒
    2020-12-25 10:29

    In case 4 you get 0x100 + sizeof x and sizeof x is 4 * sizeof int = 4 * 4 = 16 = 0x10.

    (On your system, sizeof int is 4).

提交回复
热议问题