1161: 字符串长度(指针专题)

1161: 字符串长度(指针专题)

#include<stdio.h>
int len(char *sp) 
{
    int s=0;
    while(*sp!='\0')
    {
        if(*sp!=' ')
            s++;
        sp++;      
    }
    return s;
}
int main()
{
    char a[101],*p;
    int i,s;
    p=a;
    gets(a);
    s=len(p);
    printf("%d",s);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43989856/article/details/85008807