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

  1. /*-----------------------------------------------------------------------*
  2.  * filename - strcspn.c
  3.  *
  4.  * function(s)
  5.  *        strcspn - scans a string for the first segment not containing
  6.  *                  any 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            strcspn - scans a string for the first segment not containing
  23.                           any subset of a given set of characters
  24.  
  25. Usage           size_t strcspn(const char *str1, const char *str2);
  26.  
  27. Prototype in    string.h
  28.  
  29. Description     strcspn returns the length of the initial segment of string
  30.                 str1 that consists entirely of characters not from string str2.
  31.  
  32. Return value    strcspn returns the length of the initial segment of string
  33.                 str1 that consists entirely of characters not from string str2.
  34.  
  35. *---------------------------------------------------------------------*/
  36. #if defined(__FARFUNCS__)
  37. #include <_farfunc.h>
  38. #endif
  39.  
  40. size_t _FARFUNC strcspn(const char *s1, const char *s2)
  41. {
  42.         register const char *srchs2;
  43.         int len;
  44.  
  45.         for (len = 0; *s1; s1++, len++)
  46.                 for (srchs2 = s2; *srchs2; srchs2++)
  47.                         if (*s1 == *srchs2) goto bye;
  48. bye:
  49.         return (len);
  50. }
  51.