#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
char ch1[20],ch2[20],*temp[10];
int i,j,count,k,p,q,len1,len2;
printf("Enter the string\n");
scanf("%s",ch1);
printf("Enter the string to be found\n");
scanf("%s",ch2);
for(i=0;ch1[i]!='\0';i++);
len1=i;
for(j=0;ch2[j]!='\0';j++);
len2=j;
k=0;
count=0;
for(i=0;i<len1;i++)
{
if(ch1[i]==ch2[0])
{
temp = &ch1[i];
k++;
}
}
for(i=0;i<k;i++)
{
for(p=0;p<len1;p++)
{
for(q=0;q<k;q++)
{
if(*ch1[p]==*temp[q])
{
for(j=0;j<len2;j++)
{
if(ch2[j]==ch1[p])
p++;
if(ch2[j+1]=='\0')
{
count++;
j=0;
}
}
if(ch2[j]!=ch1[p])
break;
}
}
}
}
printf("\nThe number of times word appears is\n%d\n",&count);
}
milindchawre 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.