#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int num(char* p1, char* p2,int *count) {
int ret = 0;
int tempcount = 0;
char* temp = p1;
if (p1 == NULL || p2 == NULL || count == NULL) {
printf("error");
ret -1;
}
do {
temp = strstr(temp,p2);
if (temp != NULL) {
tempcount++;
temp = temp + strlen(p2);
}
else {
break;
}
} while (*temp != '\0');
*count = tempcount;
}
int main() {
int count = 0;
char* p = "avcdefg123123456789abcdedgabcghyuabc";
char buf[] = "avc";
int ret=num(p, buf,&count );
if (count != 0) {
printf("%d\n", count);
}
system("pause");
return count;
}