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.
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.
string1<string it will return -ve.
string1=string it will return 0.
Devi achsah said:
8 years ago
Why they used const keyword in the argument?
Jaimin kathrotiya said:
8 years ago
Yes, It returns zero.
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.
Sowmi said:
9 years ago
It returns 0. Given answer is correct.
Suganthy said:
9 years ago
Yes @Sundar is right, don't confuse yourself by searching answer for it.
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.
Sanjay said:
1 decade ago
If both the strings are equal then it returns 1 otherwise 0.
Vinod said:
1 decade ago
Thanks
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.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers