#include"stdio.h"
#include"string.h"
#include"stdlib.h"
int getsubnum1(char *ch, char *sub,int * num)
{
int tem = 0;
char * f = ch;
do
{
f = strstr(f,sub);
if(f != NULL)
{
f = f + strlen(sub);
(*num)++;
}
if(f == NULL)
{
break;
}
}while(*f != '\0');
}
int getsubnum2(char *ch, char *sub,int * num)
{
int tem = 0;
char * f = ch;
for(;*f != '\0';)
{
if((f = strstr(f,sub)) != NULL)
{
f= f+strlen(sub);
(*num)++;
continue;
}
else
{
break;
}
}
}
int main()
{
char *ch = "abcd11111abcd2222abcdqqqqqabcd11111abcd2222abcdqqqqqabcd11111abcd2222abcdqqqqq";
char *sub = "abcd";
int x = 0;
getsubnum1(ch,sub,&x);
getsubnum2(ch,sub,&x);
printf("%d\n",x);
}