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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between user defined function and library function in C/C++
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- How to call function within function in C or C++
- Difference between Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- arc function in C
- fma() function in C++
- div() function in C++
- exp() function C++
- log() function in C++
- tolower() function in C
- wmemmove() function in c++
- scalbn() function in C++
- toupper() function in C
- difftime() function in C++
- wcscat() function in C++
- localtime() function in C++
- imag() function in C++
- real() function in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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