C - SizeOf Pointers

前端 未结 4 748
旧巷少年郎
旧巷少年郎 2020-11-29 14:17
char c[] = {\'a\',\'b\',\'c\'};
int* p = &c[0];
printf(\"%i\\n\", sizeof(*p)); //Prints out 4
printf(\"%i\\n\", sizeof(*c)); //Prints out 1

I a

4条回答
  •  眼角桃花
    2020-11-29 14:35

    sizeof(*p) will print size of p which is 4 because of int but c is of char that's why it is 1

提交回复
热议问题