#include <stdio.h>
#include <string.h>
int count_str(char *str, char *s)
{
char *s1, *s2;
int count = 0;
while(*str != '\0')
{
s1 = str;
s2 = s;
while(*s1 == *s3 && *s1 != '\0' && *s2!= '\0')
{
s1++;
s2++;
}
if(*s2 == '\0')
{
count++;
}
str ++;
}
return count;
}
int main(void)
{
char *str = "hehehellfdfdfhehe";
char *s = "he";
count = count_str(str, s);
printf("count: %d\n", count);
return 0 ;
}
C语言笔试题(3)——查找子串出现的次数
最新推荐文章于 2024-04-25 21:59:26 发布