//////Created And Tested By :- Rahul Upadhyay//////////////////////
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i=0,j,count=0;
char text[100],word[30],dummy[30];
clrscr();
printf("Enter text:\n");
gets(text);
printf("****************************************************");
printf("\nEnter word to search: ");
gets(word);
printf("----------------------------------------------------");
printf("\nWord occurs at: ");
while(i<strlen(text)-1)
{
j=0;
while(text[i]!='\t'&&text[i]!=' ')
{
dummy[j]=text[i];
j++;
i++;
if(i==strlen(text))
break;
}
dummy[j]='\0';
if(strcmp(word,dummy)==0)
{
printf("%d ",i-strlen(word));
count++;
}
i++;
}
if(count==0)
printf("NOWHERE");
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i=0,j,count=0;
char text[100],word[30],dummy[30];
clrscr();
printf("Enter text:\n");
gets(text);
printf("****************************************************");
printf("\nEnter word to search: ");
gets(word);
printf("----------------------------------------------------");
printf("\nWord occurs at: ");
while(i<strlen(text)-1)
{
j=0;
while(text[i]!='\t'&&text[i]!=' ')
{
dummy[j]=text[i];
j++;
i++;
if(i==strlen(text))
break;
}
dummy[j]='\0';
if(strcmp(word,dummy)==0)
{
printf("%d ",i-strlen(word));
count++;
}
i++;
}
if(count==0)
printf("NOWHERE");
getch();
}