home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / STSCHIND.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  987 b   |  41 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 psearch
  9. *        char check      Character to be searched for
  10. *        char *psearch      Pointer to the string to be searched
  11. *
  12. * Description    STSCHIND searches the string psearch for the character
  13. *        check, returning the position of its first occurrence.
  14. *        If the character does not occur, -1 is returned.
  15. *
  16. *        See also STSINDEX.
  17. *
  18. * Returns    index          The position of check in psearch
  19. *
  20. * Version    2.0 (C)Copyright Blaise Computing Inc.    1983, 1984, 1986
  21. *
  22. **/
  23.  
  24. #include <bstring.h>
  25.  
  26. #define NOTFOUND  (-1)
  27.  
  28. int stschind(check,psearch)
  29. char          check;
  30. register char *psearch;
  31. {
  32.     register int  i;
  33.     register char chs;
  34.  
  35.     for (i = 0; (chs = *psearch++); i++)
  36.     if (check == chs)
  37.        return(i);               /* Found at i..quit and return i*/
  38.  
  39.     return(NOTFOUND);
  40. }
  41.