c语言
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int fun(char *s, char *t)//寻找函数
{
int n;
char *p, *r;
n = 0;
while(*s)
{
p = s;
r = t;
while(*r)//如果不为空一直循环直到结束
if(*r == *p)
{
r++;
p++;
}
else//不相等退出
break;
if(r == '\0')
n++;
s++;
}
return n;
}
main( )
{
char s[100], t[100];
int m;
system("cls");
printf("\nPlease enter string S:" );//输入母字符串
scanf("%s", s);
printf("\nPlease enter substring t:");//输入子字符串
scanf("%s", t);
m = fun(s, t);
printf("\nThe result is : m = %d\n", m);
}
统计字符串t在字符串s中出现的次数
不知道你这个问题是否已经解决, 如果还没有解决的话: