In the below program, I was expecting the printf statement to print
a = b, b = a
But, actually it's printing
a=a, b=b
When I try to print a, b values inside function, it's giving a=b,b=a:::I do not understand why pass be reference is not influencing the actual arguments. What am I missing? Can someone please illustrate?
void swap_pointers(char* a, char* b) {
char* tmp = a;
a = b;
b = tmp;
}
int main() {
char* a = "a";
char* b = "b";
swap_pointers(a, b);
printf("a = %s, b = %s", a, b);
return 0;
}
const.