anonymous
2013-01-30 08:42:28 UTC
void main()
{
char sentence_from_user[10];
char search_data[10];
cin>>sentence_from_user;
cin>>search_data;
int total_founds=0;
//finding whether the data is present in the sentence.
int i=0;
int j=0;
for (; i
if (sentence_from_user[i]==search_data[j])
{total_founds++;
j++;
}
if (total_founds==strlen(search_data)) { cout<<"The data found at index "<
else if (sentence_from_user[i]!=search_data[j])
{ total_founds=0;
j=0;
}
}
}
for example;
char arr1[10]="123welcome";
char arr2[10]="welcome";
the program must return the index number 3 of arr1, as arr2 is present from there. However the program is not working. If you have some other logic, you may also share that.