strlen函数

strlen函数

#include <stdio.h>
int mystrlen(char *n)
{
  int i=0;
  while(*n)
  {
    i++;
    n++;
  }
  return i;
}
int main()
{
  char n[20]={"I love china";}
  int s=0;
  s=mystrlen(n);
  printf("%d\n",s);
  return 0;
}

posted on 2023-05-26 20:44  wessf  阅读(29)  评论(0)    收藏  举报