fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. char s1[] = "Hello World";
  6. char s2[] = "World"; // Add the closing quotation mark
  7. char *s3 = strstr(s1, s2);
  8. if (s3 == NULL)
  9. printf("Not found.\n");
  10. else
  11. printf("s3: %ld s1: %ld ", s3, s1);
  12. printf("Found position = %ld\n", s3 - s1); // Use %ld for pointer subtraction
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
s3: 140732084438210 s1: 140732084438204 Found position = 6