I have the following code:
str = "ABCD"; //0x001135F8
newStr = "EFGH"; //0x008F5740
*str after realloc at 5th position – //0x001135FC
I want it to point to: 0x008F5740
void str_cat(char** str, char* newStr)
{
int i;
realloc(*str, strlen(*str) + strlen(newStr) + 1); //*str is now 9 length long
// I want to change the memory reference value of the 5th char in *str to point to newStr.
// Is this possible?
// &((*str) + strlen(*str)) = (char*)&newStr; //This is my problem (I think)
}
should work – although I do not have a compiler at hand to test
or even faster and almost no pointers: http://www.koders.com/c/fid359660C181A42919DCB9E92C1406B7D16F27BB8D.aspx