#include <stdio.h> void swap (int *p, int *p2); /*propotypes declaration*/ void main() { int a1, a2, *ptr1, *ptr2; printf("Enter two integer(separate by commas):\n"); scanf("%d,%d",&a1,&a2); /*enter a1 and a2 value*/ ptr1 = &a1; /*ptr1 point to a1*/ ptr2 = &a2; /*ptr2 point to a2*/ printf("Before change the address:&a1 = %p, a2 = %p\n",&a1,&a2); /*print the address of a1 and a2*/ printf("Before change the addrees:ptr1 = %p, ptr2 = %p\n\n",ptr1,ptr2);/*print the value of ptr1 and ptr2*/ swap(ptr1, ptr2); /*call function, use pointer variable as paraments*/ printf("After change value:a1 = %d, a2 = %d\n",a1,a2); /*print the value of a1 and a2*/ printf("After change value:*ptr1 = %d, *ptr2 = %d\n",*ptr1,*ptr2); /*print the value which ptr1 and ptr2 point to*/ printf("\nAfter change the address:&a1 = %p, &a2 = %p\n",&a1,&a2); /*print a1 and a2's address*/ printf("After change the address:ptr1 = %p, ptr2 = %p\n",ptr1,ptr2);/*print ptr1 and ptr2's value*/ } void swap(int *p1, int *p2) /*define function*/ { int t; /*----------------change the value which p1 and p2 point's to----------------*/ t = *p1; *p1 = *p2; *p2 = t; }