+ 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