Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language, why can't programs exchange ab values?
C language, why can't programs exchange ab values?
Function prototype swap (int x, int y);

X and y are formal parameters. When swap(a, b) is called, x=a and y=b are assigned, and the function is no longer related to A and B. ..

The result of the exchange is only to exchange the numbers in x and y, not a and B.

If you want to exchange A and B, you should use swap (&; I. & ampb)

If you don't understand, keep asking questions.