http://acm.hdu.edu.cn/showproblem.php?pid=2087
/*
strstr(str1,str2)是一种函数,从字符串str1中查找是否有符串str2,如果有,从str1中的str2位置起,返回str1的指针,如果没有,返回null。
*/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
#define N 1010
char a[N],b[N];
int main()
{
int t;
int str;
char *p;
while(scanf("%s%s",a,b)&&a[0]!='#')//必须用scanf,而不能用gets()
{
p=a;
t=0;
str=strlen(b);
while((p=strstr(p,b))!=NULL)//strstr(p,b)
{
t++;
p+=str;//从a中b的位置返回a的指针,p+strlen(b)进入第一个b出现之后的位置进行判断
}
printf("%d\n",t);
}
return 0;
}