*** strlen.cpp

#include <iostream>
using namespace std;
unsigned int strlen1(const char * str)
{
    const char * p = str;
    while (*p++ != '\0');
    return (p-1-str);
}
int main()
{
    char a[] = "12345";
    cout << strlen1(a) << endl;
    return 0;
}

 

posted @ 2018-12-23 19:19  super行者  阅读(135)  评论(0编辑  收藏  举报