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* str1 = strstr("In relibc we trust", "rust");
  6. printf("%s\n", (str1) ? str1 : "NULL");
  7. // should be "libc we trust"
  8. char* str2 = strstr("In relibc we trust", "libc");
  9. printf("%s\n", (str2) ? str2 : "NULL");
  10. // should be "NULL"
  11. char* str3 = strstr("In relibc we trust", "bugs");
  12. printf("%s\n", (str3) ? str3 : "NULL");
  13. return 0;
  14. }