C String Functions (cont.)
- possible implementation of strcpy()
void strcpy (char* str2, const char* str1)
{
while (*str1 != '\0')
{
*str2 = *str1;
++str2;
++str1;
}
*str2 = '\0';
}
Assumption that str1 is null-terminated used
implicitly
Assumption that str2 has been allocated
sufficient memory used implicitly
C string functions do not handle or "worry about" memory management