#include<stdio.h>
#include<assert.h>
/*
*strlen函数有局部变量实现*/
int strlen1(const char* source)
{
assert(source != NULL); //断言
int length = 0;
while (*source)
{
length++;
source++;
}
return length;
}
/*strlen函数递归(无变量)实现*/
int strlen2(const char* source)
{
assert(source != NULL); //断言
if(!*source) return 0;
else
return strlen2(++source) + 1;
}
int main()
{
int length = 0;
char StrSource[20];
scanf("%s",StrSource);
length = strlen2(StrSource);
printf("这个字符串的长度是:%d",length);
return 0;
}