Javatpoint Logo
Javatpoint Logo

Wcscoll() Function in C++

In this article, we will discuss the wcscoll() function in C++ with its syntax and example.

The C++ wcscoll() function compares two strings that are null-terminated. A comparison is made based on the current locale that is specified by the LC_COLLATE category.

This function compares the initial character of every string. Until the characters diverge or a null wide character that indicates the end of a string is encountered, they are regarded as equal.

Syntax:

It has the following syntax:

Two required parameters are accepted by the function and are explained as follows:

wcs1: It is a pointer to the wide strings with null terminations that need to be compared.

wcs2: The null terminated wide strings to compare are pointed to by this pointer.

Value returned: The function yields the following three values:

  • 0, if the values show that the two strings are identical.
  • Positive value: If the first character in WCS1 that differs from WCS2 is more than that character's equivalent.
  • Negative Value: If the first character in WCS1 that differs from WCS2 is smaller than the corresponding character in WCS2, the value is negative.

Example 1:

Let's take an example to illustrate the use of wcscoll() function in C++:

Output:

In American English: apple precedes banana
In Swedish: apple precedes banana

Example 2:

Let's take another example to illustrate the use of wcscoll() function in C++:

Output:

In Czech: javatpoint precedes JTP
In American English: javatpoint precedes JTP






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA