I have the following code.According to this the values of pointers p[0] and p[1] remains unchanged since the swap is made to local variables in swap function.Now my doubt is how can I swap the pointers p[0] and p[1] inside the function swap??
Code:
- #include<stdio.h>
- int main()
- {
- char*p[2]={"hello","good morning"};
- swap(p[0],p[1]);
- printf("%s %s",p[0],p[1]);
- return0;
- }
- void swap(char*a,char*b)
- {
- char*t;
- t=a;
- a=b;
- b=t;
- }