home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 109.lha / PD_C / lib / strspn.c < prev    next >
Text File  |  1986-11-20  |  654b  |  26 lines

  1. /*
  2.  * strspn - find length of initial segment of s consisting entirely
  3.  * of characters from accept
  4.  */
  5.  
  6. SIZET
  7. strspn(s, accept)
  8. CONST char *s;
  9. CONST char *accept;
  10. {
  11.          register CONST char *sscan;
  12.          register CONST char *ascan;
  13.          register SIZET count;
  14.  
  15.          count = 0;
  16.          for (sscan = s; *sscan != '\0'; sscan++) {
  17.                    for (ascan = accept; *ascan != '\0'; ascan++)
  18.                              if (*sscan == *ascan)
  19.                                        break;
  20.                    if (*ascan == '\0')
  21.                              return(count);
  22.                    count++;
  23.          }
  24.          return(count);
  25. }
  26.