Pointer to the function to exchange two numbers

#include <stdio.h>

void swap(int  *x,int *y);

int main ()

{

       int m,n;

       scanf("%d%d",&m,&n);

       printf("before swap:m=%d n=%d\n",m,n);

       the swap ( & m, & n-);                                                  // Note reference to the function, the first two values address character.

       printf("after swap:m=%d n=%d\n",m,n);

       return 0;

}

void swap(int  *x,int *y)

{

    int temp;

    temp=*x;

    * X = * y;

    *y=temp;

}

    

    

Guess you like

Origin www.cnblogs.com/DEAKY/p/11914913.html