home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / pdc / libsrc / stringlib / strchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-07  |  439 b   |  24 lines

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