The function returns a pointer to the terminating zero.
char *str_copy (const char *strFrom, char *strTo)
{
//...
*strTo = '\0';
return strTo;
}
Change it the following way
char *str_copy (const char *strFrom, char *strTo)
{
char *p = strTo;
while ( *p++ = *strFrom++ );
return strTo;
}
Also I would declare it the same way as standard C function strcpy
is declared
char *str_copy( char *strTo, const char *strFrom );
As for your additional question then you may not assign a pointer or even other array to an array. So the compiler issues the error.
Arrays have no the assignment operator. You can only copy their elements.
Otherwise use standard class std::array
.