Home / C Programming / Strings :: Discussion

Discussion :: Strings

  1. Which of the following statement is correct?

  2. A.
    strcmp(s1, s2) returns a number less than 0 if s1>s2
    B.
    strcmp(s1, s2) returns a number greater than 0 if s1<s2
    C.
    strcmp(s1, s2) returns 0 if s1==s2
    D.
    strcmp(s1, s2) returns 1 if s1==s2

    View Answer

    Workspace

    Answer : Option C

    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.


Be The First To Comment