Changing memory address of a char*
- by Randall Flagg
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)
}