
Hi I could not found programming in C in the "select category" so I am posting my question in java section. Please help with substring function,prompt the user for two strings and display whether or not the second string is a substring of the first string.
Regards

#include<stdio.h>
#include<conio.h>
void main()
{
char str[80],sub[10];
int count1=0,count2=0,i,j,flag;
clrscr();
puts("Enter a string:");
gets(str);
puts("Enter search substring:");
gets(sub);
while (str[count1]!='\0')
count1++;
while (sub[count2]!='\0')
count2++;
for(i=0;i<=count1-count2;i++)
{
for(j=i;j<i+count2;j++)
{
flag=1;
if (str[j]!=sub[j-i])
{
flag=0;
break;
}
}
if (flag==1)
break;
}
if (flag==1)
puts("Substring is found!");
else
puts("Substring does not found!");
getch();
}

thank you for your help, but when I run the program in eclipse, I get the error message " implicit declaration of function clrscr().
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.