Computer Science, asked by priya17b01a04a4, 1 year ago

If the two strings s1 and s2 are identical, then strcmp(char *s1, char *s2) function returns

Answers

Answered by sohailabbas
0

Answer:

The strcmp() work is utilized to think about two strings two strings s1 and s2 . On the off chance that two strings are same, at that point strcmp() returns 0 , else, it restores a non-zero worth. This capacity thinks about strings character by character utilizing ASCII estimation of the characters.

Explanation:

How do you use Strcmp():

The strcmp() looks at two strings character by character. On the off chance that the primary character of two strings are equivalent, next character of two strings are analyzed. This proceeds until the relating characters of two strings are unique or an invalid character '\0' is come to. It is characterized in string.h header document.

Answered by apocritia
0

Answer:

It will return three values -1,0 and 1 depending upon the conditions explained in the explanation part.

Explanation:

The stcmp( char *s1, char *s2) compares the string and prints three values -1,0 and 1.

The following are the three cases -

1) If string s1 and string s2 both are exactly same, the stcmp(char *s1 , char *s2) will return the value 0 .

2) If the string s1 is alphabetically smaller than string s2 i.e. suppose if s1="ABCD" and S2="PQRS", the strcmp( char *s1, char *s2) will return the value -1.

3) f the string s2 is alphabetically greater than string s2 i.e. suppose if s1="PQRS" and S2="ABCD", the strcmp( char *s1, char *s2) will return the value 1.

Similar questions