Word Count Simulator

Enter Sentance
Enter any word to search:

Show Sentance Entered
								

							
Word to be searched
 
						

Code


#include <stdio.h>
#include <string.h>
#define MAX_SIZE 100
int main()
{

char str[MAX_SIZE]; char word[MAX_SIZE]; int i, j, found;
FILE *fp1;
int strLen, wordLen;
printf("Enter any word to search: ");
gets(word);

strLen = strlen(str); wordLen = strlen(word);

for(i=0; i < strLen - wordLen; i++) {
found = 1;
for(j=0; j < wordLen; j++) {

if(str[i + j] != word[j]) {
found = 0;
break;
}
}
if(found == 1)
{
printf("Word Frequency : %d \n", word, i); }

}
return 0; }

Output