home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / STSCHIND.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  977 b   |  42 lines

  1. /**
  2. *
  3. * Name        STSCHIND -- Returns the position of the first occurrence
  4. *        of a character within a string.
  5. *
  6. * Synopsis    index = stschind (check, psearch);
  7. *
  8. *        int index         The position of check within
  9. *                     psearch.
  10. *        char check         Character to be searched for.
  11. *        const char *psearch  Pointer to the string to be
  12. *                     searched.
  13. *
  14. * Description    STSCHIND searches the string psearch for the character
  15. *        check, returning the position of its first occurrence.
  16. *        If the character does not occur, -1 is returned.
  17. *
  18. * Returns    index        The position of check in psearch.
  19. *
  20. * Version    6.00 (C)Copyright Blaise Computing Inc.  1987, 1989
  21. *
  22. **/
  23.  
  24.  
  25. #include <stdio.h>    /* For definition of NULL.            */
  26. #include <string.h>
  27.  
  28. #include <bstrings.h>
  29.  
  30.  
  31. int stschind (check, psearch)
  32. char        check;
  33. const char *psearch;
  34. {
  35.     const char *p;
  36.  
  37.     if ((p = strchr (psearch, check)) == NULL)
  38.     return (-1);
  39.  
  40.     return ((int) (p - psearch));
  41. }
  42.