main(void){
int x = 10,y =20;
printf("x = %d,y = %d before\n",x,y);
printf("x address is %x\n",&x);
printf("y address is %x\n",&y);
swap(&x,&y);
printf("x = %d,y = %d after\n",x,y);
}
swap(int *px, int *py){
int temp;
temp = *px;
*px = *py;
*py = temp;
}
沒有留言:
張貼留言