C 库函数 - strcoll()

C 语言教程 · 2019-02-24 15:14:17

描述

C 库函数 int strcoll(const char *str1, const char *str2)str1str2 进行比较,结果取决于 LC_COLLATE 的位置设置。

声明

下面是 strcoll() 函数的声明。

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

参数

  • str1 -- 要进行比较的第一个字符串。
  • str2 -- 要进行比较的第二个字符串。

返回值

该函数返回值如下:

  • 如果返回值 < 0,则表示 str1 小于 str2。
  • 如果返回值 > 0,则表示 str2 小于 str1。
  • 如果返回值 = 0,则表示 str1 等于 str2。

实例

下面的实例演示了 strcoll() 函数的用法。.

实例

#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 大于 str2"); } else if(ret < 0) { printf("str2 小于 str1"); } else { printf("str1 等于 str2"); } return(0); }

让我们编译并运行上面的程序,这将产生以下结果:

str1 大于 str2

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Foundation Web Standards

Foundation Web Standards

Jonathan Lane、Steve Smith / Friends of ED / 21st July 2008 / $34.99

Foundation Web Standards explores the process of constructing a web site from start to finish. There is more to the process than just knowing HTML! Designers and developers must follow a proper proces......一起来看看 《Foundation Web Standards》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具