0024-strrchr.c (395B)
1 #include <assert.h> 2 #include <stdio.h> 3 #include <string.h> 4 5 /* 6 output: 7 testing 8 done 9 end: 10 */ 11 12 int 13 main() 14 { 15 char buf[] = "012321"; 16 17 puts("testing"); 18 assert(strrchr(buf, '1') == buf+5); 19 assert(strrchr(buf, '0') == buf); 20 assert(strrchr(buf, '3') == buf+3); 21 assert(strrchr("", '0') == NULL); 22 assert(strrchr(buf, 'a') == NULL); 23 assert(strrchr(buf, 0) == buf+6); 24 puts("done"); 25 26 return 0; 27 }