strchr.c 172 B

123456789101112131415161718
  1. #include <lib9.h>
  2. char*
  3. strchr(char *s, int c)
  4. {
  5. char c1;
  6. if(c == 0) {
  7. while(*s++)
  8. ;
  9. return s-1;
  10. }
  11. while(c1 = *s++)
  12. if(c1 == c)
  13. return s-1;
  14. return 0;
  15. }