It's clearly a homework question, even if not, a student would simply needs a 5 minute copy-pen to see what is happening here:
while( j < n )
{
for( int i = 0 ; i < m ; )
for( int j = 0 ; j < n ; )
if( B == A )
{
i++ ;
cout << "yay" ;
}
else
{
j++ ;
}
}
It's pretty clear on what is happening here. You don't need a running environment to see/debug to find the issue and implementation. Further, why not write a new one by yourself instead of correcting it, if you have that option. I see lots of issues here... starting with, if two string lengths are different what is left to be compared?