fork(5) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void) {
  5. char *str = "0010010010";
  6. char *what = "001";
  7.  
  8. int what_len = strlen(what);
  9. int count = 0;
  10.  
  11. char *where = str;
  12.  
  13. if (what_len)
  14. while ((where = strstr(where, what))) {
  15. where += what_len;
  16. count++;
  17. }
  18. printf("count = %d \n", count);
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
count = 3 	 where = (null)