Here is the strCopy implementation
void strcopy2(char *dst, char const *src){ while ((*dst++ = *src++)) ; }
Our professor asked us to reproduce this code without using pointers, so I came up with the following function:
void strcopy(char dst[], char const src[]){ size_t i = 0; while (dst[i] = src[i++]) ; }
This works well, but I realized that under the hood, the function should still use pointers, since we are not returning the value anywhere. In other words, although the latter function would use a pass by value, this is obviously not the case. So what happens under water, and is there any difference between the two methods?
source share