C Programming - Strings - Discussion

Discussion Forum : Strings - Point Out Correct Statements (Q.No. 4)
4.
Which of the following statement is correct?
strcmp(s1, s2) returns a number less than 0 if s1>s2
strcmp(s1, s2) returns a number greater than 0 if s1<s2
strcmp(s1, s2) returns 0 if s1==s2
strcmp(s1, s2) returns 1 if s1==s2
Answer: Option
Explanation:

The strcmp return an int value that is

if s1 < s2 returns a value < 0

if s1 == s2 returns 0

if s1 > s2 returns a value > 0

From the above statements, that the third statement is only correct.

Discussion:
2 comments Page 1 of 1.

Dhanashree said:   6 years ago
I didn't understand the question?

Joy said:   8 years ago
In the previous context, you affirmed that s1==s2 will only compare the address. If address are equal and strings are not equal, then this answer is wrong, because == will work with the address, not the string.

Post your comments here:

Your comments will be displayed after verification.