The value of “multidimensional array pointer +1” doesn't match

前端 未结 2 917
花落未央
花落未央 2021-01-29 12:18

Here is the problem program:

#include 
int main()
{   
    int apricot[2][3][5];
    int (*r)[5]=apricot[0];
    int *t=apricot[0][0];

    printf         


        
2条回答
  •  深忆病人
    2021-01-29 12:59

    r is a pointer to an array of 5 ints.

    Assuming 1 int is 4 bytes on your system (from t and t+1), then "stepping" that pointer by 1 (r+1) means an increase in 5*4 = 20 bytes. Which is what you get here.

提交回复
热议问题