fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. int main(void){
  7. system("cls");
  8.  
  9. char str1[30] = "Good School";
  10. char str2[30] = "oo";
  11. char* s= str2;
  12. int count = 0;
  13.  
  14. if(strstr(str1, str2)!= 0){
  15.  
  16. printf("Tim thay");
  17. }
  18. else{
  19. printf("Khong tim thay");
  20. }
  21.  
  22. for (int i = 0; i < strlen(str1); i++)
  23. {
  24. if (str1[i] == s )
  25. {
  26. count++;
  27. }
  28.  
  29. }
  30. printf("\nStr2 xuat hien trong str1 %d lan", count);
  31. }
  32.  
Success #stdin #stdout #stderr 0s 5308KB
stdin
Standard input is empty
stdout
Tim thay
Str2 xuat hien trong str1 0 lan
stderr
sh: 1: cls: not found