This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminanting null-character is reached.
Parameters
- str1
- C string to be compared.
- str2
- C string to be compared.
Return Value
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.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Output:
Guess my favourite fruit? orange Guess my favourite fruit? apple Correct answer! |
See also
| strncmp | Compare characters of two strings (function) |
| memcmp | Compare two blocks of memory (function) |
| strrchr | Locate last occurrence of character in string (function) |
| strspn | Get span of character set in string (function) |
