home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / STRCSPN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.9 KB  |  48 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. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19. #include <string.h>
  20.  
  21. /*---------------------------------------------------------------------*
  22.  
  23. Name            strcspn - scans a string for the first segment not containing
  24.                           any subset of a given set of characters
  25.  
  26. Usage           size_t strcspn(const char *str1, const char *str2);
  27.  
  28. Prototype in    string.h
  29.  
  30. Description    strcspn returns the length of the initial segment of string
  31.         str1 that consists entirely of characters not from string str2.
  32.  
  33. Return value    strcspn returns the length of the initial segment of string
  34.         str1 that consists entirely of characters not from string str2.
  35.  
  36. *---------------------------------------------------------------------*/
  37. size_t strcspn(const char *s1, const char *s2)
  38. {
  39.     register const char *srchs2;
  40.     int len;
  41.  
  42.     for (len = 0; *s1; s1++, len++)
  43.         for (srchs2 = s2; *srchs2; srchs2++)
  44.             if (*s1 == *srchs2) goto bye;
  45. bye:
  46.     return (len);
  47. }
  48.