+ 5

Compare function of C++

How the answer is 5! https://www.sololearn.com/post/493902/?ref=app

15th Aug 2020, 2:07 PM
Gorom_Pani
Gorom_Pani - avatar
5 Answers
+ 7
Position of the first character in the compared string. If this is greater than the string length, it throws out_of_range. Note: The first character is denoted by a value of 0 (not 1). len->Length of compared string (if the string is shorter, as many characters as possible). A value of string::npos indicates all characters until the end of the string.subpos, sublenSame as pos and len above, but for the comparing string. hope you understood
15th Aug 2020, 7:17 PM
AS Raghuvanshi
AS Raghuvanshi - avatar
+ 2
I think it returns the length of their difference... Well s2 - s1 results in 'learn' and it's length is 5.
15th Aug 2020, 2:12 PM
MSN
MSN - avatar
+ 2
Compare means difference here I think so learn has 5 characters so 5 is answer maybe🙇🏻‍♂️
15th Aug 2020, 2:14 PM
Prasad Bankar
Prasad Bankar - avatar
+ 1
Answer is 5 because compare() will subtract the length of s1 from length of s2
17th Aug 2020, 8:49 AM
Qamber Hasnain
Qamber Hasnain - avatar
0
Returns >0 when : Either the value of the first character that does not match is greater in the compared string, or all compared characters match but the compared string is longer.
15th Aug 2020, 2:30 PM
Hima
Hima - avatar