strlen实现
模拟实现库函数strlen
#include<stdio.h>
#include<assert.h>
//模拟实现库函数strlen
int my_strlen(const char* str){
int count = 0;
assert(str != NULL);
while (*str != '\0'){
count++;
str++;
}
return count;
}
int main(){
char arr[] = "abcdefg";
printf("%d\n", my_strlen(arr));
return 0;
}