Techhgeekz ™

Friday 27 September 2013

Program to count word from user entered text:-

#include <stdio.h>
void main()
 {
  char a[100],b[10],t[20];
  int i=0,n=0,w=1;
  printf("\n Enter The String : ");
  scanf("%s",a);
  printf("\n Enter The Word Which Count : ");
  scanf("%s",b);
  while(a[i]!='\0')
  {
  t[n]=a[i];
   if(a[i]==' ')
  {
   t[n]='\0';
 
 //printf("\n %s",t);
   n=-1;
   if(strcmp(t,b)==0)
   w++;
    }
    i++;
    n++;
    }
    printf("\n %s comes %d times ",b,w-1);

   
}


No comments:

Post a Comment