home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / STSVERFY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.2 KB  |  49 lines

  1. /**
  2. *
  3. * Name        stsverfy -- Verify that all characters in one string
  4. *        appear in another.
  5. *
  6. * Synopsis    index = stsverfy(pcheck,psearch);
  7. *
  8. *        int index      Position of leftmost character of
  9. *                  pcheck that is not in psearch
  10. *        char *pcheck      Pointer to string to be checked
  11. *        char *psearch      Pointer to string to be searched
  12. *
  13. * Description    STSVERFY returns the position of the first (leftmost)
  14. *        character of pcheck which does not appear in psearch.
  15. *        If all characters of pcheck do appear in psearch, -1 is
  16. *        returned; if pcheck has length 0, 0 is returned.
  17. *
  18. * Returns    index          The position of first character of pcheck
  19. *                  not found in psearch.
  20. *
  21. * Version    3.0 (C)Copyright Blaise Computing Inc.    1983, 1984, 1986
  22. *
  23. **/
  24.  
  25. #include <string.h>
  26.  
  27. #include <bstring.h>
  28.  
  29. #define FOUND (-1)
  30.  
  31. int stsverfy(pcheck,psearch)
  32. register char *pcheck;
  33. char          *psearch;
  34. {
  35.     register int  i;
  36.     register char ch;
  37.  
  38.     if (strlen(pcheck) == 0)
  39.        return(0);
  40.  
  41.     /* pcheck is not null, so check for each character in psearch      */
  42.  
  43.     for (i = 0; (ch = *pcheck++); i++)
  44.     if (stschind(ch,psearch) == -1)   /* Character not found       */
  45.        return(i);
  46.  
  47.     return(FOUND);               /* All characters found.        */
  48. }
  49.