Hi , I am getting an error while solving the given question , kindly help me solve the problem
Doubt in the question
hi @imsharan0105 you can use the string::find() function to see if one string is a substring of the other string or not.
Hi ,thank you for the response.
There are 2 more things i would like to know . 1)What is wrong in my answer 2)If find function cannot find the answer then what value does it return
- You are checking if only the first character is same or not. What if the strings are like bbat bbatman.
- It returns a special value
string::nposif substring is not found, else it returns the first index where its found. So you can use it like
if (s1.find(s2) != string::npos){
//this means s2 is present in s1
}
i do check within the if condition by finding out the length of the smaller string and then forming a substring out of the bigger string with the same . Once i find out the substring then i compare it u can see that within the if condition , i suppose ,still there is some problem in execution
If you could help me find out the answer there it would be great
Im so sorry . Let me do that
I have even printed then also there is some error . I’m unable to understand what is wrong with the code
hi @imsharan0105 https://ide.codingblocks.com/s/297154
there was some input related issue, you will have to use cin.ignore() while using getline() function
else you can use cin also here
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.