home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / strlen.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  1KB  |  46 lines

  1. /***
  2. *strlen.c - contains strlen() routine
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       strlen returns the length of a null-terminated string,
  8. *       not including the null byte itself.
  9. *
  10. *******************************************************************************/
  11.  
  12. #include <cruntime.h>
  13. #include <string.h>
  14.  
  15. #ifdef _MSC_VER
  16. #pragma function(strlen)
  17. #endif  /* _MSC_VER */
  18.  
  19. /***
  20. *strlen - return the length of a null-terminated string
  21. *
  22. *Purpose:
  23. *       Finds the length in bytes of the given string, not including
  24. *       the final null character.
  25. *
  26. *Entry:
  27. *       const char * str - string whose length is to be computed
  28. *
  29. *Exit:
  30. *       length of the string "str", exclusive of the final null byte
  31. *
  32. *Exceptions:
  33. *
  34. *******************************************************************************/
  35.  
  36. size_t __cdecl strlen (
  37.         const char * str
  38.         )
  39. {
  40.         const char *eos = str;
  41.  
  42.         while( *eos++ ) ;
  43.  
  44.         return( (int)(eos - str - 1) );
  45. }
  46.