i am just trying different was to pass pointer,i came across this doubt.
we can store pointer value to pointer using dereferencing i.e(*p=*q) why not we can pass through functions.
void swap(int *p,int *q)
{
int temp=*p;
*p=*q; /** when this is possible**/
*q=temp;
}
int main()
{
int a=5,b=10;
int *x,*y;
x=&a;
y=&b;
swap(&a,&b);
swap(x,y);
swap(*x,*y);/*why this is not possibel*/
}
*p=*q when this is possible.
1. swap(&a,&b);
This is possible
2. swap(*x,*y);
This is not possible. Why?
Can anyone post good material on pointers in depth.