home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 109.lha / PD_C / lib / strchr.c < prev    next >
Text File  |  1986-11-20  |  547b  |  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. CONST char *s;
  10. register char charwanted;
  11. {
  12.          register CONST 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.