/*Write a C program that displays the position or index in the string S where the string T begins, or – 1 if S doesn’t contain T.
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char a[50],b[20];
char *found;
clrscr();
printf("\n Enter the main string");
gets(a);
printf("\n Enter the b string to search in");
gets(b);
found=strstr(a,b);
if(found)
{
printf("\nSecond String is found in the First String at %d position.\n",found-a);
}
else
printf("-1");
getch();
}
No comments:
Post a Comment