zoukankan      html  css  js  c++  java
  • 字符比较 strcmp

     UCHAR  SendBuffertem[116] = "";
     UCHAR  ReadBuffertem[116] = "";

        1、 //numcmp = 116;
          //temcmp = strncmp(SendBuffertem,ReadBuffertem,numcmp);
          
          2、temcmp = strcmp(ReadBuffertem,SendBuffertem);

    对两个数组赋值一样:

    方法1比较没问题

    方法2有时正确,有时错误,不知为啥有时比较到了117,因为不一样出差

      UCHAR  formatnum = 6;//文件类型号

         strcat(destfile, fileformat[formatnum]);

    fileformat是一个字符串数组,结果出错是因为formatnum是UCHAR ;改为int即可

    char *strchr(const char *string, int c);

    查找字符c在字符串string中首次出现的位置, NULL结束符也包含在查找中.

    返回一个指针, 指向字符c在字符串string中首次出现的位置, 如果没有找到, 则返回NULL.

    char *strrchr(const char *string, int c);

    查找字符c在字符串string中最后一次出现的位置, 也就是对string进行反序搜索, 包含NULL结束符.

    返回一个指针, 指向字符c在字符串string中最后一次出现的位置, 如果没有找到, 则返回NULL.

    char *strstr(const char *string, const char *strSearch);

    在字符串string中查找strSearch子串.

    返回子串strSearch在string中首次出现位置的指针. 如果没有找到子串strSearch, 则返回NULL. 如果子串strSearch为空串, 函数返回string值.

    int strcmp(const char *string1, const char *string2);

    比较字符串string1和string2大小.

    返回值< 0, 表示string1小于string2;
    返回值为0, 表示string1等于string2;
    返回值> 0, 表示string1大于string2.

    int stricmp(const char *string1, const char *string2);

    比较字符串string1和string2大小,和strcmp不同, 比较的是它们的小写字母版本.

    返回值与strcmp相同.

    int strcmpi(const char *string1, const char *string2);

    等价于stricmp函数, 只是提供一个向后兼容的版本.

    int strncmp(const char *string1, const char *string2, size_t count);

    比较字符串string1和string2大小,只比较前面count个字符. 比较过程中, 任何一个字符串的长度小于count, 则count将被较短的字符串的长度取代. 此时如果两串前面的字符都相等, 则较短的串要小.

    返回值< 0, 表示string1的子串小于string2的子串;
    返回值为0, 表示string1的子串等于string2的子串;
    返回值> 0, 表示string1的子串大于string2的子串.

    int strnicmp(const char *string1, const char *string2, size_t count);

    比较字符串string1和string2大小,只比较前面count个字符. 与strncmp不同的是, 比较的是它们的小写字母版本.

    返回值与strncmp相同.

    char *strtok(char *strToken, const char *strDelimit);

    在strToken 串中查找下一个标记, strDelimit字符集则指定了在当前查找调用中可能遇到的分界符.

    返回一个指针, 指向在strToken中找到的下一个标记. 如果找不到标记, 就返回NULL值. 每次调用都会修改strToken内容, 用NULL字符替换遇到的每个分界符.

    内存块比较函数参考下面:
    void *memchr(const void *buf, int c, size_t count);

    在buf前面count字节中查找首次出现字符c的位置. 找到了字符c或者已经搜寻了count个字节, 查找即停止.

    操作成功则返回buf中首次出现c的位置指针, 否则返回NULL.

    void *_memccpy(void *dest, const void *src, int c, size_t count);

    从src复制0个或多个字节的字符到dest. 当字符c被复制或者count个字符被复制时, 复制停止.

    如果字符c被复制, 函数返回这个字符后面紧挨一个字符位置的指针. 否则返回NULL.

    int memcmp(const void *buf1, const void *buf2, size_t count);

    比较buf1和buf2前面count个字节大小.

    返回值< 0, 表示buf1小于buf2;
    返回值为0, 表示buf1等于buf2;
    返回值> 0, 表示buf1大于buf2.

    int memicmp(const void *buf1, const void *buf2, size_t count);

    比较buf1和buf2前面count个字节. 与memcmp不同的是, 它不区分大小写.

    返回值同上.

  • 相关阅读:
    VMware Workstation 16.0 key (仅支持 intel 架构)
    使用思科ASA对指定端口、IP进行抓包
    轮子的意义
    dubbo学习(三)泛化
    dubbo学习(二)链接
    dubbo学习(一)线程池
    mips交叉编译:SQLite3
    生成证书脚本
    ssh连接不上 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
    gmssl ocsp 验证证书
  • 原文地址:https://www.cnblogs.com/flying06/p/3850867.html
Copyright © 2011-2022 走看看