strncasecmp与strcasecmp用法 strcasecmp strncasecmp

  }
  执行 aBcDeF=AbCdEf
  注意与strncasecmp()的区别,不要弄混了。

strncasecmp

      相关函数:bcmp, memcmp, strcmp, strcoll, strncmp
  表头文件:#include <string.h>
  函数定义:int strncasecmp(const char *s1, const char *s2, size_t n)
  函数说明:strncasecmp()用来比较参数s1和s2字符串前n个字符,比较时会自动忽略大小写的差异
  返回值 :若参数s1和s2字符串相同则返回0 s1若大于s2则返回大于0的值 s1若小于s2则返回小于0的值
  #include <string.h>
  main()
  {
  char *a="aBcddfefekr";
  char *b="AbCddfefekr";
  printf("%d/n", strncasecmp(a, b));
  }
  亦可用在指定结束与程序入口
  eg:if(!strncasecmp(buffer,"quit",4))
  break;
  eg:if(!strncasecmp(buffer,"work",4)){
  printf("hello,world!");
  break;
  }