home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / string.arc / STRCHR.C < prev    next >
Text File  |  1984-12-31  |  1KB  |  28 lines

  1. /*  File   : strchr.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 20 April 1984
  4.     Defines: strchr(), index()
  5.  
  6.     strchr(s, c) returns a pointer to the  first  place  in  s  where  c
  7.     occurs,  or  NullS if c does not occur in s. This function is called
  8.     index in V7 and 4.?bsd systems; while not ideal the name is  clearer
  9.     than  strchr,  so index remains in strings.h as a macro.  NB: strchr
  10.     looks for single characters,  not for sets or strings.   To find the
  11.     NUL character which closes s, use strchr(s, '\0') or strend(s).  The
  12.     parameter 'c' is declared 'int' so it will go in a register; if your
  13.     C compiler is happy with register _char_ change it to that.
  14. */
  15.  
  16. #include "strings.h"
  17.  
  18. char *strchr(s, c)
  19.     register _char_ *s;
  20.     register int c;
  21.     {
  22.     for (;;) {
  23.         if (*s == c) return s;
  24.         if (!*s++) return NullS;
  25.     }
  26.     }
  27.