C strcoll() Function

C strcoll() Function

The strcoll() function compares two strings depends upon the LC_COLLATE settings.

Example

C Compiler
#include <stdio.h> #include <string.h> #include <locale.h> int main() { char str1[] = "Hallo"; char str2[] = "HALLO"; // de_DE - German setlocale(LC_COLLATE, "de_DE.UTF-8"); int res = strcoll(str1, str2); if(res == 0) printf("str1 is equal to str2"); else if(res > 0) printf("str1 is greater than str2"); else printf("str1 is less than str2"); return 0; }

Syntax

int strcoll(const char *str1, const char *str2)

Parameter Values

ValueTypeExplanation
str1RequiredSpecifies the string 1
str2RequiredSpecifies the string 2

Return Value

ValueExplanation
-1If str1 is less than str2
0If str1 is equal to str2
1If str1 is greater than str2

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author