I have a homework assignment where I have to create a function called add_string(char **existing, const char *add) which also returns a **char type. The goal is to basically make a new array that copies all of the existing array of strings and appends the add string on the end as well.
I am having some difficulty figuring out how to actually iterate through the **existing array that has been passed through.
I have tried inputing a for loop and looping that way. I tried just outputting existing, with printf("%c", *existing[0]); And my most recent attemp has been this:
char *ptr = *existing;
while(ptr != NULL)
{
printf("test");
fflush(stdout);
ptr++;
}
Currently my output is this:
timeout: the monitored command dumped core
Could anybody help me figure out how to correctly iterate through this array of strings?
then