185. C Program to Search a Word Position from the Given String.
How does this program work?
- This Program is used to search a word from the given string.
Here is the code
#include <stdio.h>
#include <string.h>
int main()
{
char s[30], t[20];
char *found;
//Enter input string
puts("Enter the first string: \n");
gets(s);
puts("Enter the word to search: \n");
gets(t);
// To Searching word in string
found=strstr(s,t);
if(found)
printf("The Word is found in the First String at %d position.\n",found-s);
else
printf("-1");
}