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 sentance: ");
gets(str);
printf("Choose file ");
fp1= fopen (filepath, "r");
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;
}