C language code for the exchange of pointer variables

. 1 #include <stdio.h>
 2  void the swap ( int * P1, int * P2)
 . 3  {
 . 4      int tmp; // Note that this must be a variable rather than a pointer, access pointer field error
 . 5      tmp * = P1;
 . 6      * P1 = * P2;
 . 7      * P2 = tmp;
 . 8  }
 . 9  int main ()
 10  {
 . 11      int A, B;
 12 is      A = . 5 ;
 13 is      B = 10 ;
 14      the swap (& A, & B); // parameter is when should address pointer variable transmission
15     printf("%d %d",a,b);
16     return 0;
17 }

Guess you like

Origin www.cnblogs.com/shareicts/p/12167590.html