zoukankan      html  css  js  c++  java
  • 字符串比较函数总结

    文章转自: http://liuzhigong.blog.163.com/blog/static/178272375201133104113718/

    strcasecmp(忽略大小写比较字符串)
      相关函数 bcmp,memcmp,strcmp,strcoll,strncmp
      表头文件 #include<string.h>
      定义函数 int strcasecmp (const char *s1, const char *s2);
      函数说明 strcasecmp()用来比较参数s1和s2字符串,比较时会自动忽略大小写的差异。
      返回值 若参数s1和s2字符串相同则返回0。s1长度大于s2长度则返回大于0 的值,s1 长度若小于s2 长度则返回小于0的值。
     
    strncasecmp(忽略大小写比较两个字符串前n个字符)
           函数定义:int strncasecmp(const char *s1, const char *s2, size_t n)
      函数说明:strncasecmp()用来比较参数s1和s2字符串前n个字符,比较时会自动忽略大小写的差异
      返回值 :若参数s1和s2字符串相同则返回0 s1若大于s2则返回大于0的值 s1若小于s2则返回小于0的值

     
    strcmp(比较两个字符串大小,大小写敏感)
           函数定义:extern int strcmp(const char *s1,const char * s2);
      函数说明:strcmp()用来比较参数s1和s2字符串,比较时不会忽略大小写的差异
      返回值 :当s1<s2时,返回值<0   当s1=s2时,返回值=0   当s1>s2时,返回值>0 
      即:两个字符串自左向右逐个字符相比(按ASCII值大小相比较),直到出现不同的字符或遇''为止。如:
      "A"<"B"      "a">"A"      "computer">"compare"
  • 相关阅读:
    Pascal's Triangle II
    Pascal's Triangle
    Best Time to Buy and Sell Stock II
    Best Time to Buy and Sell Stock
    Populating Next Right Pointers in Each Node
    path sum II
    Path Sum
    [转载]小波时频图
    [转载]小波时频图
    [转载]Hilbert变换及谱分析
  • 原文地址:https://www.cnblogs.com/batteryhp/p/5020478.html
Copyright © 2011-2022 走看看