The wcsncmp() function in C/C++ compare characters of two wide strings. The comparison is done lexicographically. This function takes three arguments lhs, rhs and count. It compares the contents of lhs and rhs lexicographically upto a maximum of count wide characters.
Note: The behaviour of wcsncmp() is undefined if either of lhs or rhs do not point to null terminated wide strings.
int wcsncmp( const wchar_t* lhs, const wchar_t* rhs, size_t count )
Parameter :The function accepts three mandatory parameters which are described below:
- lhs : String to be compared
- rhs : String to be compared
- count : Maximum number of characters to compare
Return value: The function returns three value as below:
- Positive value: if the first differing character in lhs is greater than the corresponding character in rhs.
- Negative value: if the first differing character in lhs is less than the corresponding character in rhs.
- Zero: if the characters compared in both the strings form the same string.
Below programs illustrate the above function:
Program 1 :
First 4 characters of are same geekGgeek precedes geekforgeeks
Program 2 :
First 5 characters of are same First 8 characters of are same
- How to call some function before main() function in C++?
- Function Overloading vs Function Overriding in C++
- How to call function within function in C or C++
- What happens when a virtual function is called inside a non-virtual function in C++
- Difference between Virtual function and Pure virtual function in C++
- log() function in C++
- exp() function C++
- div() function in C++
- fma() function in C++
- arc function in C
- Modulus function in C++ STL
- transform_inclusive_scan() function in C++
- wcstol() function in C/C++
- wcstod() function in C/C++
- wcsncat() function in C/C++
Improved By : Akanksha_Rai