home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / stringlb.lzh / STRINGLIB / STRCHR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-01  |  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.