C语言实现strlen(char *str)
[cpp]
#include <stdio.h>
int mylen(char *str);
int main()
{
char *str = "haha";
printf("len = %d", mylen(str));
return 0;
}
int mylen(char *str)
{
if(str == NULL) return 0;
int len = 0;
for(; *str++ != '\0';)
{
len++;
}
return len;
}
#include <stdio.h>
int mylen(char *str);
int main()
{
char *str = "haha";
printf("len = %d", mylen(str));
return 0;
}
int mylen(char *str)
{
if(str == NULL) return 0;
int len = 0;
for(; *str++ != '\0';)
{
len++;
}
return len;
}
补充:软件开发 , C语言 ,