栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

strcasecmp()--忽略大小写比较字符串

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

strcasecmp()--忽略大小写比较字符串

strcasecmp()的功能是:忽略大小写比较字符串

头文件 #include

函数原型:int strcasecmp(const char *s1, const char *s2);

函数功能: 用来比较参数s1和s2字符串,比较时会自动忽略大小写的差异。

返回值: 若参数字符串s1和字符串s2相等则返回0,s1大于s2则返回大于0 的值,s1 小于s2 则返回小于0的值。

#include 
#include 
#include 

int main() {
  char *a="ZLib";
  char *b="zlIB";
  char *c="NonE";
  char *d="none";
  
  if (0 == strcasecmp(a, b)) {
    std::cout << "result : a == b" << std::endl;
  } else {
    std::cout << "result : a != b" << std::endl;
  }
  
  if (0 == strcasecmp(c, d)) {
    std::cout << "result : c == d" << std::endl;
  } else {
    std::cout << "result : c != d" << std::endl;
  }
  
  return 0;
}

在C++ shell上的执行结果如下:

编译工具的连接地址:C++ Shell

如有疑问请发邮件:zgaoq@163.com

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/302883.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号