模拟实现strlen

#include<stdio.h>
#include<stdlib.h>

int Strlen(const char* str) {
 if (str == NULL) {
  return NULL;
 }
 int size = 0;
 while (*str != '\0') {
  size++;
  str++;
 }
 return size;
}


int main() {
 char str[] = "abcdef";
 int len = Strlen(str);
 printf("%d\n", len);
 
 system("pause");
 return 0;
}
发布了47 篇原创文章 · 获赞 4 · 访问量 487

猜你喜欢

转载自blog.csdn.net/weixin_45818891/article/details/104747179