fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. const char *p1, *p2;
  5. char text[] = "<AAA>hello world</AAA>";
  6.  
  7. p1 = strstr(text, "<AAA>");
  8. p1 += 5;
  9. if (p1 == NULL) return -1;
  10. p2 = strstr(p1, "</AAA>");
  11. if (p2 == NULL || p2 < p1) return -2;
  12. printf("'%.*s'\n", (int)(p2 - p1), p1);
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0s 2156KB
stdin
Standard input is empty
stdout
'hello world'