zoukankan      html  css  js  c++  java
  • windows c++ 比较字符串 不区分大小写

    //z 2014-04-18 17:41:49 BG57IV3@XCL T745044962 .K.F253293061 [T244,L3296,R157,V4779]
    使用函数 StrStrI 比较字符串,不区分大小写。
    StrStrI function
    Finds the first occurrence of a substring within a string. The comparison is not case-sensitive.
    Return value
    
    包含头文件 Shlwapi.h
    库 Shlwapi.lib
    注意:与 wcstr 不同,在传入一个空字符串时,会返回 NULL 。
    
    Type: PTSTR
    Returns the address of the first occurrence of the matching substring if successful, or NULL otherwise.
    
    
    Header Shlwapi.h
    Library Shlwapi.lib
    
    
    nlike strstr() and wcsstr() passing an emtpy string results in NULL being returned.
    
    
    pszFound = StrStrI(L"abcdefg", L""); // returns NULL
    pszFoundStrStr = wcsstr(L"abcdefg", L""); // returns L"abcdefg"
    
    
    char *strstr(
       const char *str,
       const char *strSearch 
    ); // C only
    char *strstr(
       char *str,
       const char *strSearch 
    ); // C++ only
    const char *strstr(
       const char *str,
       const char *strSearch 
    ); // C++ only
    wchar_t *wcsstr(
       const wchar_t *str,
       const wchar_t *strSearch 
    ); // C only
    wchar_t *wcsstr(
       wchar_t *str,
       const wchar_t *strSearch 
    ); // C++ only
    const wchar_t *wcsstr(
       const wchar_t *str,
       const wchar_t *strSearch 
    ); // C++ only
    unsigned char *_mbsstr(
       const unsigned char *str,
       const unsigned char *strSearch 
    ); // C only
    unsigned char *_mbsstr(
       unsigned char *str,
       const unsigned char *strSearch 
    ); // C++ only
    const unsigned char *_mbsstr(
       const unsigned char *str,
       const unsigned char *strSearch 
    ); // C++ only
    unsigned char *_mbsstr_l(
       const unsigned char *str,
       const unsigned char *strSearch,
       _locale_t locale
    ); // C only
    unsigned char *_mbsstr_l(
       unsigned char *str,
       const unsigned char *strSearch,
       _locale_t locale
    ); // C++ only
    const unsigned char *_mbsstr_l(
       const unsigned char *str,
       const unsigned char *strSearch,
       _locale_t locale
    ); // C++ only
    
    //z 2014-04-18 17:41:49 BG57IV3@XCL T745044962 .K.F253293061 [T244,L3296,R157,V4779]
    
    
    Generic-Text Routine Mappings

    TCHAR.H routine

    _UNICODE & _MBCS not defined

    _MBCS defined

    _UNICODE defined

    _tcsstr

    strstr

    _mbsstr

    wcsstr

    n/a

    n/a

    _mbsstr_l

    n/a

    // crt_strstr.c
    
    #include <string.h>
    #include <stdio.h>
    
    char str[] =    "lazy";
    char string[] = "The quick brown dog jumps over the lazy fox";
    char fmt1[] =   "         1         2         3         4         5";
    char fmt2[] =   "12345678901234567890123456789012345678901234567890";
    
    int main( void )
    {
       char *pdest;
       int  result;
       printf( "String to be searched:
       %s
    ", string );
       printf( "   %s
       %s
    
    ", fmt1, fmt2 );
       pdest = strstr( string, str );
       result = (int)(pdest - string + 1);
       if ( pdest != NULL )
          printf( "%s found at position %d
    ", str, result );
       else
          printf( "%s not found
    ", str );
    }
    /* strstr example */
    #include <stdio.h>
    #include <string.h>
    
    int main ()
    {
      char str[] ="This is a simple string";
      char * pch;
      pch = strstr (str,"simple");
      strncpy (pch,"sample",6);
      puts (str);
      return 0;
    }


    String to be searched:
       The quick brown dog jumps over the lazy fox
                1         2         3         4         5
       12345678901234567890123456789012345678901234567890
    
    lazy found at position 36

    @IS2120#CNBLOGS.T2169364049[T1,L65,R1,V259]:备忘
    $ € ₤ ₭ ₪ ₩ ₮ ₦ ₱ ฿ ₡ ₫ ﷼ ¥ ﷼ ₫ ₡ ฿ ₱ ₦ ₮ ₩ ₪ ₭ ₤ € $
  • 相关阅读:
    lombk在IDEA中报ClassNotFoundException错误
    Groovy在不同JDK版本下的性能差异
    Groovy中那些神奇注解之InheritConstructors
    Groovy中那些神奇注解之ToString
    Groovy中那些神奇注解之Memoized
    写个自己的远程桌面
    JAVA的BIT数组
    基于JDK 8的Dubbo Admin
    走进Groovy (二)
    走进Groovy (一)
  • 原文地址:https://www.cnblogs.com/IS2120/p/6745666.html
Copyright © 2011-2022 走看看