OK, I know it works, I jst want to know why.
OK, here is the deal, for examlpe I have a function:
Code:
void function(char s[]);
and I want it to take the character array as input and manipulate it and then exit.
here is an example invocation. why i am trying to accomplish is to take the array string and change its value from test to temp.
Code:
main(){
char string[MAX];
string="test";
function(string);
printf("%s",string);
}
ok the function written like this gets the desired resuts, the vaiable s is set to "temp" in the function and retains this value when the function exits and string is back in the main program.
Code:
void function(char s[]){
sscanf("temp","%s",s);
}
now my question is why when written this way, it does not get the desired result.
Code:
void function(char s[]){
char t[MAX];
sscanf("temp","%s",t);
s=t;
}
within the scope of the function s and t are correct, however when the function exists, back in main, string does not retain the value.
I have a feeling this has something to do with pointers and referencing of the arrays, I'm just not sure what. Any additional reference material for this as well.
Thanks!
--ellipses--