Strcmp of "abc" and "abd" will be 0, right? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Strcmp of "abc" and "abd" will be 0, right?

30th Aug 2020, 7:33 AM
Aayu
5 Answers
+ 5
The strcmp method will perform string comparison based on the given strings and returns any of the following three values: It will return -1 if str1 is less than the data inside str2 Returns +1, if str1 is greater than data inside the str2 and, it will return 0, if str1 and str2 are equal
30th Aug 2020, 7:54 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
How bout you try it? I got -1
30th Aug 2020, 7:39 AM
Slick
Slick - avatar
30th Aug 2020, 7:39 AM
RuntimeERROR
RuntimeERROR - avatar
+ 1
ཞıɬıƙą ɱıʂɧཞą it's not about data actually, it's about the Difference in ascii characters in both strings :) https://code.sololearn.com/cN3Aabe8EsH1/?ref=app see its returning 4 and -4 respectively
30th Aug 2020, 7:56 AM
RuntimeERROR
RuntimeERROR - avatar
0
https://code.sololearn.com/clqhLnsR7RJD/?ref=app yeah, it's true Netha_r2071, it's the difference in ASCII characters.
30th Aug 2020, 8:17 AM
Aayu