home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / STRSPN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.6 KB  |  56 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - strspn.c
  3.  *
  4.  * function(s)
  5.  *        strspn - scans a string for the first segment that is a
  6.  *                 subset of a given set of characters
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <string.h>
  19.  
  20. /*---------------------------------------------------------------------*
  21.  
  22. Name            strspn - scans a string for the first segment that is a
  23.                          subset of a given set of characters
  24.  
  25. Usage           size_t strspn(const char *str1, const char *str2);
  26.  
  27. Prototype in    string.h
  28.  
  29. Description     strspn returns the length of the initial segment of string
  30.                 str1 that consists entirely of characters from string str2.
  31.  
  32. Return value    strspn returns the length of the initial segment of string
  33.                 str1 that consists entirely of characters from string str2.
  34.  
  35.  
  36. *---------------------------------------------------------------------*/
  37. #if defined(__FARFUNCS__)
  38. #include <_farfunc.h>
  39. #endif
  40.  
  41. size_t _FARFUNC strspn(const char *s1, const char *s2)
  42. {
  43.         register const char *srchs2;
  44.         int                 len;
  45.  
  46.         for (len = 0; *s1; s1++, len++)
  47.         {
  48.                 for (srchs2 = s2; *srchs2; srchs2++)
  49.                         if (*s1 == *srchs2)
  50.                                 break;
  51.                 if (*srchs2 == 0)
  52.                         break;
  53.         }
  54.         return (len);
  55. }
  56.