strcoll() in c is a library function use to compares string str1 to str2 and result will depends on result is the LC_COLLATE setting of the location.
Syntax for strcoll() in c
int strcoll(const char *str1, const char *str2)
Parameters for strcoll():-
str1 & str2 are two Parameters which is going to use for strcoll() function in c.
Read more :- Arc function in C with graphics in c
Return Value :-
if return value is < 0 then it indicates that str1 is less than str2 or Return value > 0 then it indicates that str2 is less than str1 and the last one Return value = 0 than str1 is equal to str2.
Example program for strcoll() in c
#include<stdio.h> #include <string.h> int main () { char str1[15]; char str2[15]; int ret; strcpy(str1, "abc"); strcpy(str2, "ABC"); ret = strcoll(str1, str2); if(ret > 0) { printf("str1 is less than str2"); } else if(ret < 0) { printf("str2 is less than str1"); } else { printf("str1 is equal to str2"); } return(0); }
0 comments:
Post a Comment