Hello, I am studying pointers and I encountered this program:
#include <stdio.h>
void swap(int *,int *);
int main()
{
int a=10;
int b=20;
swap(&a,&b);
printf("the value is %d and %d",a,b);
return 0;
}
void swap(int *a,int*b)
{
int t;
t=*a;
*a=*b;
*b=t;
printf("%d and%d\n",*a,*b);
}
Can any one tell me why this main function return the value reversed? The thing I understood till now is that the function call in C does not affect the main function and it's values.
I also want to know how much the space a pointer variable occupied like integer have occupied the 2 bytes and the various application use and advantages of the pointer...