#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int statisticString(char *str,const char *findStr)
{
if (NULL == str)
{
return -1;
}
int num = 0;
char *p = str;
while (1)
{
p = strstr(p, findStr);
if (p == NULL)
{
return num;
}
p += strlen(findStr);
num++;
}
return num;
}
void test()
{
char *p = "asdsffgacd.,g.f,.fg, abcwwacdw";
char *findStr = "wac";
int num = statisticString(p, findStr);
printf("%d ",num);
}
void main()
{
test();
system("pause");
}
统计字符串的个数
最新推荐文章于 2023-05-23 17:00:57 发布