swapping two pointers code example
Example: swap two numbers using pointers
#include
#include
void swap(int *a,int *b);
void main()
{
int a = 20;
int b = 30;
printf("Before swapped: a = %d and b = %d\n",a,b);
swap(&a,&b);
printf("Swapped result: a = %d and b = %d\n",a,b);
getch();
}
void swap(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}