Use strcoll function to compare two string with locale information

Syntax

C strcoll function has the following format.

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

C strcoll function is from header file string.h.

Description

C strcoll function compares the *str1 to *str2 in accordance with the locale specified using the setlocale() function.

Return

C strcoll function returns an integer that is interpreted as follows:

Value Meaning
<0 str1 is less than str2
0 str1 is equal to str2
>0 str1 is greater than str2

Example

Use C strcoll function to compare two string with locale information.


#include<stdio.h>
#include<string.h>
/*from  w  ww . ja v a  2s . co  m*/
int main(void){

    if(strcoll("hi", "hi")) {
       printf("Equal");
    }

} 




















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h