/****************************************
* Program to find the location *
* of a word in a given string *
*****************************************/
#include
#include
void main(void)
{
int i,j,k=0,len=0;
char str[50],str1[20];
clrscr();
printf("enter the string");
gets(str);
printf("enter the string u wan to search");
gets(str1);
i=0;
while(str[i]!='\0')
{
len++;
i++;
}
i=0;
j=0;
while(j
{
if(str[j]==str[i])
{
j++;
}
else
{
j=0;
}
if(str[i]==' ')
{
k++;
}
i++;
}
if(j==len)
{
printf("string is present at**>%d location",k);
}
getch();
}
#include
void main(void)
{
int i,j,k=0,len=0;
char str[50],str1[20];
clrscr();
printf("enter the string");
gets(str);
printf("enter the string u wan to search");
gets(str1);
i=0;
while(str[i]!='\0')
{
len++;
i++;
}
i=0;
j=0;
while(j
{
if(str[j]==str[i])
{
j++;
}
else
{
j=0;
}
if(str[i]==' ')
{
k++;
}
i++;
}
if(j==len)
{
printf("string is present at**>%d location",k);
}
getch();
}
No comments:
Post a Comment