#include <stdio.h>
int mystrlen(const char *str)
{
int i;
if(str == NULL)
return -1;
for(i = 0; str[i] != '\0'; i++);
return i-1;
}
int main(void)
{
int res;
char str[] = "hello world!";
res = mystrlen(str);
printf("------res = %d------\n",res);
return 0;
}
size_t strlen(const char *s):统计s指针指向的内存中的数据的个数,除\0,通过返回值返回