同一字母不能出现在两个子串中,字符串中有多少单独子字符串

要求没看明白,是查找字符串1中有多少个字符串2吗?

这样的话代码如下:

#include <stdio.h>
#include <string.h>
#include <ctype.h>
//查找big串中所有smal串的位置,并把位置存放在pos中,nmb存放个数
void findstr(char*big ,char* smal,int pos[],int *nmb)
{
	int i,j,lenb,lens;
	lenb = strlen(big);
	lens = strlen(smal);
	*nmb = 0;
	if(lens > lenb)
		return;

	i = 0;
	while(i < lenb-lens+1)
	{
		for (j = 0; j < lens;j++)
		{
			if(tolower(big[i+j]) != tolower(smal[j]))
				break;
		}
		if (j == lens) //说明找到
		{
			pos[*nmb] = i;
			(*nmb)++;
			i += lens;
		}else
			i++;
	}
}

int main()
{
	char buf1[100] ={0};
	char buf2[100] = {0};
	int pos[20];
	int nmb = 0;
	printf("请输入两个字符串:");
	gets(buf1);
	gets(buf2);
	findstr(buf1,buf2,pos,&nmb);
	printf("%s中含有%s的个数为%d\n",buf1,buf2,nmb);
	return 0;
}

 

你可以先说明你的思路嘛?