2
0

strrchr.c 502 B

12345678910111213141516171819202122232425
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "test_helpers.h"
  5. int main(void) {
  6. char s0[] = "hello, world";
  7. char *ptr = strrchr(s0, 'l');
  8. if (ptr != &s0[10]) {
  9. printf("%p != %p\n", ptr, &s0[10]);
  10. puts("strrchr FAIL");
  11. exit(EXIT_FAILURE);
  12. }
  13. char s1[] = "";
  14. ptr = strrchr(s1, 'a');
  15. if (ptr != NULL) {
  16. printf("%p != 0\n", ptr);
  17. puts("strrchr FAIL");
  18. exit(EXIT_FAILURE);
  19. }
  20. puts("strrch PASS");
  21. }