C Programming - Strings - Discussion

Discussion Forum : Strings - General Questions (Q.No. 2)
2.
If the two strings are identical, then strcmp() function returns
-1
1
0
Yes
Answer: Option
Explanation:

Declaration: strcmp(const char *s1, const char*s2);

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

Discussion:
14 comments Page 2 of 2.

Uday said:   9 years ago
Actually there is a pointer function before strings. So if we give equal values to both strings but address are different, because strings are different.

Jaimin kathrotiya said:   9 years ago
Yes, It returns zero.

Devi achsah said:   8 years ago
Why they used const keyword in the argument?

Sandhya said:   8 years ago
I think if string1>string2 it will return +ve.
string1<string it will return -ve.
string1=string it will return 0.


Post your comments here:

Your comments will be displayed after verification.