` char *copy(char *array){
int i, counter = 0;
counter = strlen(array);
char *arraycopy = (char*) malloc (sizeof(char) * counter + 1); //the +1 is for the null terminator at the end
int j;
for(j = 0; j < counter; j++){ //it's better to use counter here as you already know the length of your array. you program might //segment fault if check the length of your copyarray
arraycopy[j] = array[j];
}
arraycopy[counter] = array[counter]; //you can use calloc if you don't want to write the null terminator manually
return arraycopy;
i recommend you to run your code with -g -fsanitize=address when you compile. it help you to detect some error with memory and don't forget to free your copy in main when it's not needed anymore
}`