C: Does the address operator (&) produce a pointer (address + type) or just an address?

后端 未结 4 1369
感动是毒
感动是毒 2021-01-14 23:30

Most of what I\'ve read about the address operator, &, says it\'s used to get just that - an address. I recently heard it described differently, though, as

4条回答
  •  一个人的身影
    2021-01-14 23:48

    The variable i1 has type int, so the expression &i1 takes the address of an int, yielding an expression of type int *. This expression is then assigned to p1, which is also of type int *.

    So now p1 points to the memory location of i1, so the expression *p1 will be 5.

提交回复
热议问题