#include <stdio.h>
int main()
{
int i;
i=0;
printf("%d\n%d\n%d\n", i, &i, &(&i));
return 0;
}
i think that &i is just a value of address, and assume that it's 0xFF so &(&i)should be the address of 0xFF but why it's not valid?
#include <stdio.h>
int main()
{
int i;
i=0;
printf("%d\n%d\n%d\n", i, &i, &(&i));
return 0;
}
i think that &i is just a value of address, and assume that it's 0xFF so &(&i)should be the address of 0xFF but why it's not valid?
Unary & operator need an lvalue as its operand and returns an rvalue. &i is an rvalue, therefore &i can't be an operand of &.
6.5.3.2.
- The operand of the unary & operator shall be either a function designator, the result of a [] or unary * operator, or an lvalue that designates an object that is not a bit-field and is not declared with the register storage-class specifier.
&i is an address of an object.
This means that unary &cannot be used on &i, as the address doesn't designate an object or a function, nor is the result of [] or * operator.
Your example is effectively: &0, and constant 0 obviously doesn't fall on the above list.
Don't confuse addresses and pointers.An address is an rvalue.You can't apply the "address of"(&) operator on it.Pointers however are objects.They are lvalue-s and can be the operand of '&'.
Easy, look at it this way. You got a bee nest. In a square I put some honey. Using the & operator you refer to that square. Using again the & operator you refer to the square in which the square is located, you can`t do that.
More precisely &i refer to the memory location is i. You can`t refer to the memory location of a memory location.