#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
int my_strlen(char *str)
{
assert(str);
if (*str == '\0')
{
return 0;
}
else
{
return my_strlen(++str) + 1;
}
}
int main()
{
int ret = 0;
char a[10] = "abcdef";
ret = my_strlen(a);
printf("%d\n", ret);
system("pause");
return 0;
}
【c语言】递归实现strlen函数
最新推荐文章于 2024-04-26 23:23:13 发布