Memory addresses should not be interpreted as signed integers in that way. The sign of the number depends on the highest bit set (assuming two's complement representation, which is used by the vast majority of systems currently in use), so a memory address above 0x80000000 on a 32-bit system will be negative, and a memory address below 0x80000000 will be positive. There's no real significance to that.
You should be printing memory addresses using the %p
modifier; alternatively, some people use %08x
for printing memory addresses (or %016llx
on 64-bit systems). This will always print out as an unsigned integer in hexadecimal, which is far more useful than a signed decimal integer.
int a;
printf("%p
", &a);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…