home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / strcspn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1.1 KB  |  66 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strcspn.c,v 1.1 1996/12/11 11:18:28 aros Exp $
  4.  
  5.     Desc: ANSI C function strcspn()
  6.     Lang: english
  7. */
  8.  
  9. /*****************************************************************************
  10.  
  11.     NAME */
  12. #include <string.h>
  13.  
  14.     size_t strcspn (
  15.  
  16. /*  SYNOPSIS */
  17.     const char * str,
  18.     const char * reject)
  19.  
  20. /*  FUNCTION
  21.     Calculates the length of the initial segment of str which consists
  22.     entirely of characters not in reject.
  23.  
  24.     INPUTS
  25.     str - The string to check.
  26.     reject - Characters which must not be in str.
  27.  
  28.     RESULT
  29.     Length of the initial segment of str which doesn't contain any
  30.     characters from reject.
  31.  
  32.     NOTES
  33.  
  34.     EXAMPLE
  35.     char buffer[64];
  36.  
  37.     strcpy (buffer, "Hello ");
  38.  
  39.     // Returns 5
  40.     strcspn (buffer, " ");
  41.  
  42.     // Returns 0
  43.     strcspn (buffer, "H");
  44.  
  45.     BUGS
  46.  
  47.     SEE ALSO
  48.  
  49.     INTERNALS
  50.  
  51.     HISTORY
  52.     11.12.1996 digulla created
  53.  
  54. ******************************************************************************/
  55. {
  56.     size_t n;
  57.  
  58.     while (*str && !strchr (reject, *str))
  59.     {
  60.     str ++;
  61.     n ++;
  62.     }
  63.  
  64.     return n;
  65. } /* strcspn */
  66.