strcoll() is a built-in library function and is declared in <string.h> header file. This function compares the string pointed to by str1 with the one pointed by str2.The strcoll() function performs the comparison based on the rules of the current locale’s LC_COLLATE category.
Syntax:
int strcoll(const char *str1, const char *str2)
Parameters: Function strcoll() takes two strings as parameters and returns an integer value.
Value Meaning less than zero str1 is less than str2 zero str1 is equal to str2 greater than zero str1 is greater than str2
strcoll()
is a C/C++ library function that is used for string comparison. It is defined in the <string.h>
header file in C and <cstring>
in C++. The function is similar to strcmp()
, which is also used for string comparison, but strcoll()
performs a locale-specific comparison of strings.
Locale-specific comparison means that the comparison of strings takes into account the language and cultural context in which the strings are used. This is important because the ordering of characters may vary depending on the language and region. For example, in English, the letter "a" comes before "b," but in Swedish, the letter "a" comes after "z." strcoll()
handles these differences by comparing strings according to the current locale settings.
The syntax for strcoll()
is as follows:
int strcoll(const char* str1, const char* str2);
The function takes two arguments, str1
and str2
, which are the strings to be compared. The function returns an integer value, which is negative if str1
is less than str2
, zero if they are equal, or positive if str1
is greater than str2
.
In summary, strcoll()
is a useful function for performing locale-specific comparisons of strings, which can be important in multilingual applications.
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.