fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main (void)
  5. {
  6. char a[]="SEND OK BLA BLA BLA.. BLA BLA BLA.. HTTP: ...BLA BLA BLA... Connection...bla";
  7. char s[]="SEND OK HTTP: Connection"; //string with words you want to chceck
  8. char *ret ,*token;
  9. int index=0; // declare index
  10. token=strtok(s," "); // tokenize s
  11. while(token!=NULL){ // check return of strtok
  12. ret=strstr(a,token); // search words
  13. if(ret!=NULL) // check return of strstr
  14. index++; // increment index
  15. token=strtok(NULL," ");
  16. }
  17. printf("%d",index); // print index
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
4