Hi i got a function that looks like this:
The output is:Code:int main(void){ char * string; char * string2; string=test(1); printf("%s\n",string); string2=test(2); printf("%s\n",string); } char * test(int i){ char * string; if(i==1) string="test1"; else string="test2"; return string; }
test1
test2
instead of: (what i want to have)
test1
test1
How can I solve this problem?
(I already tryed strcpy() but that didn't work either)
Thanks in advance,
Castelmagno