#include<stdio.h>
int my_strlen(char*str)
{
if (*str != '\0')
return 1 + my_strlen(str + 1);
else
return 0;
}
int main()
{
int ret = 0;
char arr[] = "hi bit";
ret = my_strlen(arr);
printf("字符串长度为%d", ret);
return 0;
}
#include<stdio.h>
int my_strlen(char*str)
{
if (*str != '\0')
return 1 + my_strlen(str + 1);
else
return 0;
}
int main()
{
int ret = 0;
char arr[] = "hi bit";
ret = my_strlen(arr);
printf("字符串长度为%d", ret);
return 0;
}