Stuck on codeacademy string copier problem

I have been stuck on the “String Copier” problem in the codeacademy C course for a very long time as many of the tasks are unclear on what exactly to do.
Here is what I have so far (I never got past task 5):

#include<stdio.h>
#include<string.h>
 
void copy(char* dst, char* src){
  // Code for copying a string goes here
  while(*src!='\0'){
    *src[0]=&dst;
    src++;
    dst++;
  }
  dst[strlen(src)+1]='\0';
}
 
int main(){
  char srcString[] = "We promptly judged antique ivory buckles for the next prize!";
 
}

void copy(char* dst, char* src)
{
while( *src != ‘\0’)
{
*dst = *src;
src++;
dst++;
}
*dst = ‘\0’;
}

#include<stdio.h>
#include<string.h>

void copy(char* dst, char* src){
while(src != “\0”) {
*dst = *src;
src++;
dst++;
}
dst != “\0”;
}

int main(){
char srcString = “We promptly judged antique ivory buckles for the next prize!”;
char dstString[strlen(srcString +1)];
strcpy(dstString, srcString);
printf(“%s”, dstString);
}

I’ll see if I can shed some light; anyone with more knowledge, please feel free to correct any mistakes in my language.

The first thing to note is that in the copy() function, we are simply taking 2 pointers as inputs. This means we aren’t “expecting” an array per se, so it might help to think of the *ptr as contents, and &ptr as an address. The *ptr takes the value stored at address location &ptr. An analogy that might help, &ptr is locker number 12, but *ptr is the content(s) in the locker. When we say &ptr, we are “referencing” the locker (number 12), and when we say *ptr we are “de-referencing” to find out what is inside the locker (the contents).

Since we are “just expecting” 2 pointers, we are “just expecting” values. So in the first line of your while loop you wrote:

*src[0] = &dst;

We can ignore the index (the [0] part), because we are dealing with 2 values. Therefore we can just write:

*dst = *src;

dst should be on the left, since that’s where we want these values to end up, and src is on the right, since we are taking the values from there.

Our loop will copy the values in *src to *dst, and then increment both by 1, so they point to the next memory location. At the end of the loop, we will be pointing to the “final” memory location for both src and dst. Here you put:

dst[strlen(src)+1] = '\0';

However, since both dst and src will be pointing to the final location (because we incremented inside the while loop before we checked the condition and exited), we can just set dst to be the null terminator:

*dst = '\0';

(Just reiterating, but we aren’t “expecting” arrays, just values, so we avoid the dst[index] part).
This will end our dst string.

In the main() section of the code we have to create the destination array (char dst[]). The nice thing about the strlen() function is that it takes care of making the arrays the same length, so we don’t have to worry about adding +1 like we would if we did it manually (so just char dstString[strlen(srcString)];). Here’s a little thing I put in my code to prove that to myself:

  if(dstString[strlen(srcString)] == '\0'){
    printf("Final value is \'\\0\' \n");
  }

You can change it to be:

char dstString[strlen(srcString) + 1];
copy(dstString, srcString);
if(dstString[strlen(srcString) + 1] == '\0'){
  printf("Final value is \'\\0\' \n");
}

and see what it prints out (it should be nothing).

Edit: fixed my final example to be more correct.