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
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- fma() function in C++
- exp() function C++
- log() function in C++
- div() function in C++
- arc function in C
- regex_iterator() function in C++ STL
- putchar() function in C
- map key_comp() function in C++ STL
- Inline function in C
- strol() function in C++
- unordered_map end( ) function in C++ STL
- strcspn() function in C/C++
- array at() function in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai