zoukankan      html  css  js  c++  java
  • memcmp,memicmp函数

    函数原型:extern int memcmp(void *str1, void *str2, unsigned int n)

    参数说明:str1和str2为指定作比较的字符串,比较两个字符串的前n个字节。
            
    所在库名:#include <string.h>
      
    函数功能:比较字符串str1和str2在内存区域中的的前n个字节是否相同。
      
    返回说明:当str1<str12时,返回值<0;当str11=str12时,返回值=0;当str11>str12时,返回值>0。

    其它说明:暂时无。

    实例:

    #include <string.h>
    #include 
    <stdio.h>

    int main()
    {
        
    char *str1="I'm sky2098,welcome to my website!";
        
    char *str2="I'm sky2098,please do not call me sky2098!";
        
    int inttemp;
        inttemp
    =memcmp(str1,str2,strlen("I'm sky2098,"));   //比较str1和str2在内存区中前strlen("I'm sky2098,")个字节是否相等
        if(inttemp==0)
       
    {
          printf(
    "str1 and str2 has n bytes which are the same as each other!/n");
       }

       
    return 0;
    }

    在VC++ 6.0  编译运行:

    尤其注意了,memcmp函数实现的是字节的比较,而不是字符的比较。

     

     

    函数原型:extern int memicmp(void *str1, void *str2, unsigned int count)

    参数说明:str1和str2为指定作比较的字符串,比较两个字符串的前count个字节,不区分大小写。
            
    所在库名:#include <string.h>
      
    函数功能:比较字符串str1和str2在内存区域中的的前count个字节是否相同。
      
    返回说明:当str1<str12时,返回值<0;当str11=str12时,返回值=0;当str11>str12时,返回值>0。

    其它说明:暂时无。

    实例:

    #include <string.h>
    #include 
    <stdio.h>

    int main()
    {
        
    char *str1="I'm sky2098,welcome to my website!";  //两个字符串含义相同,但是大小写不同
        
    char *str2="I'm SKY2098,WELCOME TO MY website!";
        
    int inttemp;
        inttemp
    =memicmp(str1,str2,strlen("I'm sky2098,welcome to my website!"));   //比较str1和str2在内存区中前strlen("I'm sky2098,welcome to my website!")个字节是否相等
        if(inttemp==0)
       
    {
          printf(
    "str1 and str2 has n bytes which are the same as each other! ");
       }

       
    return 0;
    }

     

    在VC++ 6.0  编译运行:

    memicmp函数在比较的时候是不区分字母大小写的。

     

  • 相关阅读:
    [bbk2908]第4集 Chapter 03 介绍RAC的体系结构
    [bbk3011]第8集 Chapter 05 介绍RAC安装过程概述
    [bbk3100]第7集 Chapter 04 介绍RAC中CVU工具的使用
    [bbk2907]第3集 Chapter 02 RAC的安装过程中需要注意的要点
    [bbk2905]第1集 Chapter 01 介绍RAC概述
    [bbk2906]第2集 Chapter 02 介绍RAC概述
    RAC之CRS架构简介
    NOIP普及组2017比赛总结
    struct和typedef
    KMP详解(转)
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5835355.html
Copyright © 2011-2022 走看看