home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libfake / strchr.c < prev    next >
C/C++ Source or Header  |  1989-05-27  |  408b  |  22 lines

  1. /*
  2.  * strchr - find first occurrence of a character in a string
  3.  */
  4.  
  5. #define    NULL    0
  6.  
  7. char *                /* found char, or NULL if none */
  8. strchr(s, charwanted)
  9.  char *s;
  10. register char charwanted;
  11. {
  12.     register  char *scan;
  13.  
  14.     /*
  15.      * The odd placement of the two tests is so NUL is findable.
  16.      */
  17.     for (scan = s; *scan != charwanted;)    /* ++ moved down for opt. */
  18.         if (*scan++ == '\0')
  19.             return(NULL);
  20.     return(scan);
  21. }
  22.