3 - strlen

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 ;
}

你可能感兴趣的:(3 - strlen)