chek if array B is substring of A

\\i am not getting why is this not working well
\\ input:string A and B
\\output:tell whether B is substring of A or not


#include <iostream>
using namespace std;

int main(){
char A[100];
cout<<"enter string a";
cin>>A;

char B[75];
cout<<"enter string b";
cin>>B;
int lenb=0;
int lena=0;
int i=0;

int j=0;
int k;

for(;B[i]!='\0';i++)
lenb++;

for(;A[j]!='\0';j++)
lena++;
i=0;
j=0;

while(j<lena){
if(A[j]=B[i])
{ for(k=0;A[j]=B[i];k++){
i++;
j++;}}
else j++;;
}

if (k=(lenb-1))
{cout<<"is substring";}
else cout<<"is not substring";

}
Last edited on
How about B = "ABCD", A = "ABABCDEF"
i don't understand where my code goes wrong.@kbw
Topic archived. No new replies allowed.