strstr.c 475 B

123456789101112131415161718
  1. #include <string.h>
  2. #include <stdio.h>
  3. int main(int argc, char* argv[]) {
  4. // should be "rust"
  5. char* res1 = strstr("In relibc we trust", "rust");
  6. printf("%s\n", (res1) ? res1 : "NULL");
  7. // should be "libc we trust"
  8. char* res2 = strstr("In relibc we trust", "libc");
  9. printf("%s\n", (res2) ? res2 : "NULL");
  10. // should be "NULL"
  11. char* res3 = strstr("In relibc we trust", "bugs");
  12. printf("%s\n", (res3) ? res3 : "NULL");
  13. return 0;
  14. }