pointer in c and the c program
- by sandy101
Hello,
I am studying the pointer and i come to 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 ....
plz.... anyone help