Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C (Can you assign pointer variables to integer variables?
C (Can you assign pointer variables to integer variables?
It is still possible under the transformation of the strengthening system.

take for example

p =(int)p 1;

Not like you, p = * p1; This is to assign the value pointed by the pointer to p.

It should be noted that this assignment is lossless for compilers with 32 bits or less.

that is

p =(int)p 1;

p2 =(int *)p;

There is no problem accessing *p2 at this time.

If it is 64 bits, it may lead to overflow when the pointer is assigned to int, and the value is truncated, resulting in data loss.