A program that checks if a string is a substring of another....!
#include<iostream>
using namespace std;
#include<cstring>
int main()
{
char a[100];
char b[50];
int i=0;
int j=0;
int lb=strlen(b);
int la=strlen(a);
bool is=false;
cout<<"please input a string"<<endl;
cin.get(a,100);
char garbage;
cin.get(garbage);
cout<<"now enter a string to check if it is a substring"<<endl;
cin.get(b,50);
while(la>=lb&&a[i]!='\0')
{
if(a[i]==b[j])
{i++;
j++;
is=true;}
if(a[i]!=b[j])
{i++;
is=false;
j=0;}
}
if(is=true)
cout<<"yes"<<endl;
if(is=false)
cout<<"no"<<endl;
}
__________________
Books all say different things while people flap their yellow wings trying
to soar by being a whore of life!!!! 
|