Short answer: The first function gets copies of the pointers and you just modify these copies, not what the original pointer actually points too.
Longer: The second function takes gets pointer-to-pointer "copies" that which in turn (presumably) containts the addresses to the original location of your real pointers. In that function you change what the original pointers point to.
If we compare a pointer to an int, an int variable has an address in memory, and the value at that memory address is the number that the int contains. int a = 4
, a
has an adress at which the number 4
is stored. Same goes for pointers. A pointer say char *b = "cde"
, b
has an address where it's value is stored. A pointer contains the "value" that is another address, in this case the address to where the string "cde" is stored.
So what happens in your first function is that you send the value of str1
or str2
, not the address to str1
/str2
themselves. If you send the address of str1/str2 as in the second example, you are sending a pointer-to-pointer
(char**
) and it will work.