Life is Good.

Enhance Tech and English
随笔 - 65, 文章 - 20, 评论 - 21, 引用 - 0
数据加载中……

3 - strlen

/***
*strlen - return the length of a null-terminated string
*
*Purpose:
*       Finds the length in bytes of the given string, not including
*       the final null character.
*
*Entry:
*       const char * str - string whose length is to be computed
*
*Exit:
*       length of the string "str", exclusive of the final null byte
*
*Exceptions:
*
******************************************************************************
*/

size_t __cdecl strlen ( 
const char * str  )
{
  
const char *eos = str;

  
while*eos++ ) ;

  
return( (int)(eos - str - 1) );
}

int _tmain(int argc, _TCHAR* argv[])
{
  
char str[] = "abcde";
  
int n = strlen(str);

  
return 0;
}

posted on 2011-06-02 21:38 Mike Song 阅读(173) 评论(0)  编辑 收藏 引用 所属分类: C字符串函数源码分析


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理