Hello guys,
I have this function:
void swap(char **a, char **b) {
char *tmp=*a;
*a=*b;
*b=tmp;
}
int main() {
char *str1="aaa";
char *str2="bbb";
swap((char **)&str1, (char**)&str2);
return 0;
}
The program runs and really swaps the two strings.
I don't understand why we send (char**)&str1 and (char**)&str2 as an arguments.
And when doing *a in the function... what do we really get? The str1 string? or the pointer to it?
Can somebody explain what is going here?
Thanks