Computer Science - Object Oriented Programming Using C++ - Discussion

Discussion Forum : Object Oriented Programming Using C++ - Section 11 (Q.No. 12)
12.
The function strcmp("Jose", "JOSE") will return _____
- 1
0
1
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
5 comments Page 1 of 1.

Ayesha said:   5 years ago
stricmp() is one of the inbuilt string functions in c programming which is used to compare two strings without any discrimination between uppercase and lowercase letters if the strings are same, it returns 0. Otherwise, it returns a nonzero value.

And the syntax is;

strcmp
strcmp("Jose", "JOSE")
char leftStr[] = "Jose";
char rightStr[] = "JOSE";
Strings are unequal
Value of result: 1

char leftStr[] = "Jose";
char rightStr[] = "Jose";
c

z has greater ASCII value than g
char leftStr[] = "zfz";
char rightStr[] = "gfg";

Strings are unequal
Value of result: >1 like 19

b has less ASCII value than g
char leftStr[] = "bfb";
char rightStr[] = "gfg";

Strings are unequal
Value of result: <1 like (-5)

Lucifer said:   7 years ago
strcmp(str1,str2) returns 0 if two strings are equal.
Returns -1 if str2 is > str1.
Returns 1 if str1 is > str2.

Rashi Jain said:   8 years ago
That means here 1 is for false.

Bipin said:   9 years ago
strcmp checks case sensitive chars. So 1.

Sana said:   9 years ago
Why it will return 1?

Post your comments here:

Your comments will be displayed after verification.