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, until a terminating null-character is reached, or until num characters match in both strings, whichever happens first.
Parameters
- str1
- C string to be compared.
- str2
- C string to be compared.
- num
- Maximum number of characters to compare.
Return Value
Returns an integral value indicating the relationship between the strings:A zero value indicates that the characters compared in both strings are all 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 16 |
|
Output:
Looking for R2 astromech droids... found R2D2 found R2A6 |
See also
| strcmp | Compare 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) |
