C语言,用指针编写一个求字符串长度的函数(不要用strlen函数)

C语言,用指针编写一个求字符串长度的函数(不要用strlen函数)指针,不能用strlen函数

#include <stdio.h>
int len(char *s)
{
    char *p;
    for(p=s;*p;p++);
    return p-s;
}
int main()
{
    printf("%d\n",len("Hello World"));

    return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-06-25
int Mystrlen(char *p)
{
int i=0;
while(*(p+i)!='\0') i++;
return i;
}