C Programming - Strings - Discussion
Discussion Forum : Strings - General Questions (Q.No. 2)
2.
If the two strings are identical, then strcmp() function returns
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 1 of 2.
Yag said:
1 decade ago
I think it will return 1.
Sundar said:
1 decade ago
Returns an integral value indicating the relationship between the strings:
A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2; And a value less than zero indicates the opposite.
A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2; And a value less than zero indicates the opposite.
Deepu said:
1 decade ago
String compares compare two string if they are same it will return 1 else return 0. Any one give more explanation.
Ankit said:
1 decade ago
What Sundar said is correct.
Shri said:
1 decade ago
When you compare any two strings at that time compiler will return 0.
And this logic is used to find palindrome string.
And this logic is used to find palindrome string.
Vinod said:
1 decade ago
Thanks
Sanjay said:
1 decade ago
If both the strings are equal then it returns 1 otherwise 0.
Jagdish said:
1 decade ago
@Sunder is right. It will return only 0 when both string are similar otherwise it will return 1 or -1.
Suganthy said:
9 years ago
Yes @Sundar is right, don't confuse yourself by searching answer for it.
Sowmi said:
9 years ago
It returns 0. Given answer is correct.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers