Original Post
im wondering why passing a pointer to a function, and then setting that pointer to something in the function, does not return it back.
example:
void SetValue(char *name)
{
name = "billy joel";
}
void SetValueTwo(char *&name)
{
name = "billy gates";
}
void main()
{
char *name = "billy madison";
SetValue(name);
printf("%s\n",name);
// the above will print "<null>"
SetValueTwo(name);
printf("%s\n",name);
// the one above will print "billy gates"
}
i cant understand the passing by reference and why that works.
but im not sure why passing as a simple pointer would NOT work, since I am passing a pointer to a string.