sizeof behaving unexpectedly

前端 未结 4 1055
再見小時候
再見小時候 2021-01-04 09:02

Consider the following code:

  #include 
  int main(void)
  {
    int a[10];
    printf(\"%d\",(int)sizeof(a)); //prints 10*sizeof(int) (40 on         


        
4条回答
  •  渐次进展
    2021-01-04 09:16

    Nope, in the second case the argument is interpreted as an int* pointer which happens to also have size equal to 4 on your machine.

提交回复
热议问题