传入字符串,计算字符串长度(用指针实现)

int strlen(char *s)
{
    int i=0;
    while(*s!='')
    {
        i++;
        s++;
    }
    return i;
}

void main()
{
    char str[100];
    int len;
    printf("please input your string:");
    gets(str);
    len=strlen(str);
    printf("the length of str is:%d
",len);
}
原文地址:https://www.cnblogs.com/bhlsheji/p/5327671.html