Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Can I assign the address of an integer variable to a real pointer?
Can I assign the address of an integer variable to a real pointer?
This problem, in fact, is possible from the perspective of simple transformation, such as:

int a = 1; float * p = & ampa;

This transformation can be compiled, but it is completely meaningless, mainly depending on the binary storage mode of float, and the resulting structure may not be what you want.

I feel that there is something wrong with the sentence "an int* pointer can only be assigned an element address of type int". LZ is just an int and a float (or double). If you use short or char to convert int, you can actually get the correct answer. Give a warning at most when compiling.

int a = 1; float * p = & ampa; char * p 1 = & amp; a;

The result of *p should not be 1, but the result of *p 1 must be 1.