I am attempting to change the value of an original string by changing a pointer.
Say I have:
char **stringO = (char**) malloc (sizeof(char*));
*stringO = (char*) malloc (17);
char stringOne[17] = "a" ;
char stringTwo[17] = "b";
char stringThree[17] = "c";
char newStr[17] = "d";
strcpy(*stringO, stringOne);
strcpy(*stringO, stringTwo);
strcpy(*stringO, stringThree);
//change stringOne to newStr using stringO??
How can I change stringOne
so its the same as newStr
using the pointer stringO
?
edit: I guess the question was rather unclear. i want it to modify the latest string that *strcpy
was copied from. So if strcpy(*stringO, stringThree);
was last called, it will modify stringThree
, strcpy(*stringO, stringTwo);
then string Two
etc.