How can I return to a string address and then assign it to a new string?
Posted
by Y_Y
on Stack Overflow
See other posts from Stack Overflow
or by Y_Y
Published on 2010-04-12T00:08:49Z
Indexed on
2010/04/12
0:13 UTC
Read the original article
Hit count: 168
I have 1 function that I want to return the address of an assigned string to the main function and assign an new string pointer with the same address so that the new string will have the contents of the old string.
For example:
unknown_datatype function()
{
char *old = "THE STRING";
return old;
}
int main()
{
char *snew = "";
snew = function();
return 0;
}
*unknown_datatype means I don't know that to put there...
*How can I approach this without changing anything in the main() method
© Stack Overflow or respective owner