using namespace std;
for(int i=0;i<4;i++) cin>>s2[i];
if(s1.find(s2[i]) !=string::npos) c++;
The error was that u didn’t write ‘#’ before including the the libraries .
Just add that and your code will work:)
The error is because you are comparing parts of the string and not the whole word for example
cook chef is good
coo ch no bad
will give you output similar but the result should be dissimilar
the reason for the output to be similar is s1.find(s2[i]) if true for coo as it finds “coo” in “cook”
So just take 2 string 1-D arrays of size 4 and compare each word if then c>2 print similar else dissimilar. I
hope this helps :)!!
actually he added ‘#’ but since he just pasted it directly # is converted into heading due to markdown.