@piyush
the output will hello piyush........it's due to following reason
you've declared array of 2 pointers to character(char *pstr[2]),which means
hello and piyush are stored somewhere else but your array is having only
starting addresses of each string.........now when you are calling swap
function you are passing these addresses as a copy to formal parameters t1
and t2...if you really want to see the change in main function then you have
to do call by reference.....i.e. instead of sending copy of content of your
array of pointers,send the address of that location where your pointer is
stored in array of pointers(i.e. send addresses of pstr[0] and pstr[1]
instead of sending values of pstr[0] and pstr[1])...............for this to
work,your function should be
swap(char** t1,char** t2){
char *t;
t=*t1;
*t1=*t2;
*t2=t;
}if still there is problem then you need to revise concept of pointers...Let Us C or pointer in C would help -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
