s1 = “Apple”
s2 = “Mango”
s1.compare(s2)
why the comparison return the character ?
s1 = “Apple”
s2 = “Mango”
s1.compare(s2)
why the comparison return the character ?
Means why it return the integer value?
compare function is predefined function which does lexicographic comparison of the two strings
It returns:
0 : if both strings are equal.
A value < 0 : if s1 < s2
A value > 0 : if s1 > s2
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.