【c语言】实现一个函数,求字符串的长度,不同意创建第三方变量

//  实现一个函数,求字符串的长度。不同意创建第三方变量。

#include <stdio.h>
#include <assert.h>

int my_strlen_no(char const *p)
{
	assert(p != NULL);
	if (*p == NULL)
		return 0;
	else
		return (1 + my_strlen_no(p + 1));
}

int main()
{
	char *p = "zhaoyaqian";
	printf("长度是:%d\n", my_strlen_no(p));
	return 0;
}






posted @ 2017-04-18 10:21  zsychanpin  阅读(297)  评论(0)    收藏  举报