swap two pointers code example
Example: swap two numbers using pointers
#include<stdio.h>
#include<conio.h>
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;
}