C语言-用字符数组实现函数strlen()

#include

unsigned int myStrlen(char str[]);

int main()
{
    char a[80];
    unsigned int len;
    printf("Pleas enter a string:");
    gets(a);
    len = myStrlen(a);
    printf("The length is:%u\n", len);
}

unsigned int myStrlen(char str[])
{
    int i;
    unsigned int len = 0;
    for (i = 0; str[i] != '\0'; i++)
    {
        len++;
    }
    return len;
}

 

你可能感兴趣的:(蓝桥杯,c语言)