The wcscmp() function is defined in cwchar.h header file. The wcscmp() function is used to compares two null terminating wide string and this comparison is done lexicographically.
int wcscmp(const wchar_t* str1, const wchar_t* str2);
Parameters: This method takes the following two parameters:
- str1: This represents the pointer to the first string to be compare.
- str2: This represents the pointer to the second string to be compare.
Return Value: This method returns:
- Zero: If the str1 and str2 are same.
- Positive value: If the first different character in str1 is greater than the corresponding character in str2.
- Negative value: If the first different character in str1 is less than the corresponding character in str2.
Below programs illustrate the above function:-
Comparing Computer and Science = -1 Comparing Science and Science = 0 Comparing Science and Computer = 1