So I need to make a function that takes a parameter of type char **
, and makes that point to a string.
I've spent hours on it and I know it's probably a super dumb thing that I'm missing.
Here is my latest attempt:
void magic_string(char ** new_string) {
char * my_string = (char*) malloc((5+1)*sizeof(char));
my_string = "abcde";
new_string = &my_string;
}
But when I try to use the new_string
in the calling function, it is still null
.
I also tried replacing the last line with *new_string = my_string
but recieved a bad access exception.