一,int myStrlen(const char *s);
size_t myStrlen(const char *s)
{
size_t cnt = 0;
while(*s++ != '\0')
{
cnt++;
}
return cnt;
}
二,char *myStrcpy(char *dest, const char *src);
char *myStrcpy(char *dest, const char *src)
{
char *temp = dest;
if(src == NULL || dest == NULL)
{
return NULL;
}
while((*dest++ = *src++) != '\0');
return temp;
}
三,char *myStrncpy(char *dest, const char *src, size_t n)
char *myStrncpy(char *dest, const char *src, size_t n)
{
char *temp = dest;
if(!n)
{
return temp;
}
while( (n--) && (*dest++ = *src++) != '\0');
*dest = '\0';
return temp;
}