When you say y = x
in this case it just means that y
assumes whatever pointer value x
happened to have. You never initialized x
with a value, so it's just some random junk.
The address of x
and y
themselves is going to be different. These are two separate variables representing two separate pointers. You can assign their value to be the same, but their address remains distinct.
You're probably confusing this behaviour with:
int x = 5;
int* y = &x;
Where now y == &x
but &x
and &y
continue to remain distinct.
As C does not have references, you really don't have situations where two independent variables are ever the same address.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…