#include <stdio.h>
#include <assert.h>
int myStrlen(const char * str) {
assert(str != (void*)0);
int i = 0;
while (*str++ != '\0') {
i++;
}
return i;
}
int main() {
printf("%d \n" , myStrlen("1"));
return 0;
}
自己实现一个 strlen 函数(获取字符串长度)
最新推荐文章于 2023-10-06 16:22:24 发布