well here goes the code
#include<stdio.h>
main()
{
char a[20],b[5],c[20];
int i=0,j=0,k=0,count=0;
printf("Enter the string u want to search in");
gets(a);
printf("enter the word u want to search");
gets( b );
while(i!=strlen(a)-1)
{
if(a[i]==' ')
{ for(j=k;j<=i-1;j++)
{c[j-k]=a[j];}
c[j+1]="\0";
k=j+2;
if (strcmp(b,c)==0)
{
count++;
}
}
i++;
}
printf("%d",count);
}
This post has been edited by groovicus: 26 November 2010 - 08:54 AM

Help


Back to top











