Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - On the pointer assignment in C language!
On the pointer assignment in C language!
int a=3,b=4,*x,* y;

* x = a; * y = b;

Pointer variables x, y are not initialized, and uncertain values (junk values) are stored in variables. Indirect access to uncertain memory locations is illegal. So "* x = a;; * y = b; "Illegal." * x = & ampa; * y = & ampb; "Similarly, whether the types on both sides of the assignment number" = "are compatible or not is ignored here for the time being.

int a=3,b=4,*x,* y;

x = & ampa; y = & ampb; //& amp; A, A & ampB take the addresses of variables A and B respectively, and then assign values to pointer variables X and Y. ..

At this time, X points to A (the address where X stores A), Y points to B, and A can be accessed through *x (*x and A are equivalent). In this case, * x and A both represent the same storage location. So what you wrote in the end is correct. Remember, before accessing the pointer indirectly, make sure that the pointer points to a clear memory location.