Pointers to pointers vs. normal pointers

前端 未结 12 1271
南旧
南旧 2021-01-30 08:33

The purpose of a pointer is to save the address of a specific variable. Then the memory structure of following code should look like:

int a = 5;
int *b = &a;         


        
12条回答
  •  误落风尘
    2021-01-30 08:35

    There are different types. And there is a good reason for it:

    Having …

    int a = 5;
    int *b = &a;
    int **c = &b;
    

    … the expression …

    *b * 5
    

    … is valid, while the expression …

    *c * 5
    

    makes no sense.

    The big deal is not, how pointers or pointers-to-pointers are stored, but to what they refer.

提交回复
热议问题