I am writing memcpy from scratch and I have been looking up other peoples implementations...My implementation is:
void* memcpy (void *destination, const void *source, size_t num)
{
char *D = (char*)destination;
char *S = (char*)source;
for(int i = 0; i < num; i++)
D[i] = S[i];
return D;
}
various other sources and references that I have researched have
void* memcpy (void *destination, const void *source, size_t num)
{
char *D = (char*)destination;
char *S = (char*)source;
for(int i = 0; i < num; i++)
{
*D = *S;
D++;
S++;
}
return D;
}
I am having trouble understanding the difference and whether they would produce different outputs. The portion that confuses me specifically is the D++; and S++;