6-19 strlen (10分)

6-19 strlen (10分)
 

Implement the strcmp() as in the standard library.

函数接口定义:

int mylen( const char *s );
 

裁判测试程序样例:

#include <stdio.h>

int mylen( const char *s );

int main()
{
  char word[80];
  scanf("%s", word);

  printf("%d", mylen(word));

  return 0;

}

/* 请在这里填写答案 */
@@@

 

输入样例:

hello
 

输出样例:

5




int mylen( const char *s )
{
 int str_len=0;
 while(*s++!='\0')
 {
  str_len++;
  
 }
 return str_len;
}
posted @ 2020-10-19 20:27  罪梦者  阅读(253)  评论(0)    收藏  举报