C/C++ 中的 strcoll()
strcoll() 函式用於使用特定於區域設定的排序序列比較兩個字串。
它返回−
- 當兩個字串相同時的零值,
- 當第一個字串大於另一個字串時的大於零的值
- 當第一個字串小於另一個字串時的小於零的值。
以下是 C 語言中 strcoll() 的語法,
int strcoll(const char *first_string, const char *second_string);
以下是 C 語言中 strcoll() 的一個示例,
示例
#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);
}輸出
String s1 is greater than string s2
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言
C++
C#
MongoDB
MySQL
Javascript
PHP