Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strcoll() in C/C++
The function strcoll() is used to compare two strings using locale - specific collating sequence.
It returns −
- zero, when both strings are same,
- greater than zero value when first string is greater than other
- less than zero value, when first string is less than other.
Here is the syntax of strcoll() in C language,
int strcoll(const char *first_string, const char *second_string);
Here is an example of strcoll() in C language,
Example
#include <stdio.h>
#include <string.h>
int main () {
const char s1[] = "Helloworld";
const char s2[] = "Blank";
char *result;
result = strcoll(s1, s2);
if(result > 0)
printf("String s1 is greater than string s2");
else if(result < 0)
printf("String s1 is less than string s2");
else
printf(" Strings are not same");
return(0);
}
Output
String s1 is greater than string s2
Advertisements