Pointer to the first null-terminated string to compare.
2nd Parameter Type : const char *
Pointer to read-only string
2nd Parameter
Pointer to the second null-terminated string to compare.
Read more about parameters of strcmp in parameters section
The strcmpfunction in C language Compares two strings lexicographically.
The strcmp function compares the C string str1 to the C string str2. 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 terminating null-character is reached.
The strcmpfunction takes 2
parameters:
•
const char * `s1`: Pointer to the first null-terminated string to compare.
•
const char * `s2`: Pointer to the second null-terminated string to compare.
Compares two null-terminated strings `s1` and `s2` lexicographically. Returns a value less than, equal to, or greater than zero if `s1` is found to be less than, equal to, or greater than `s2`, respectively.
The strcmp function return value :
Returns an integer less than, equal to, or greater than zero if str1 is found, respectively, to be less than, to match, or be greater than str2
Output
This example demonstrates basic usage of strcmp to compare different strings.