strlen函数实现
/1.不创建新变量/
int my_strlen2(const char *str)
{
assert(str != NULL);
if (*str++ != ‘\0’)
{
return 1 + my_strlen2(str);
}
else
{
return 0;
}
}
/2./
int my_strlen(const char *str)
{
int count = 0;
assert(str != NULL);
while (*str++ != ‘\0’)
{
count++;
}
return count;
}