C语言-指针-用指针实现函数strlen()

#include

unsigned int MyStrlen(const char *pstr);

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);
    return 0;
}

unsigned int MyStrlen(const char *pStr)
{
    int i;
    unsigned int len = 0;
    for (; *pStr != '\0'; pStr++)
    {
        len++;
    }
    return len;
}

 

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