• Cstring的使用


    https://msdn.microsoft.com/zh-cn/aa315043

    1、字符串提取函数,CString::Left、CString::Mid 、CString::Right

    CString::Mid 

    CString Mid( int nFirst ) const; throw( CMemoryException );

    CString Mid( int nFirst, int nCount ) const; throw( CMemoryException );

    Return Value

    A CString object that contains a copy of the specified range of characters. Note that the returned CString object may be empty.

    Parameters

    nFirst

    The zero-based index of the first character in this CString object that is to be included in the extracted substring.

    nCount

    The number of characters to extract from this CString object. If this parameter is not supplied, then the remainder of the string is extracted.

    Remarks

    Extracts a substring of length nCount characters from this CString object, starting at position nFirst (zero-based). The function returns a copy of the extracted substring. Mid is similar to the Basic MID$ function (except that indexes are zero-based).

    For multibyte character sets (MBCS), nCount refers to each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two characters.

    Example

    The following example demonstrates the use of CString::Mid.

    // example for CString::Mid
    CString s( _T("abcdef") );
    ASSERT( s.Mid( 2, 3 ) == _T("cde") );

    CString::Left 

    CString Left( int nCount ) const; throw( CMemoryException );

    Return Value

    A CString object containing a copy of the specified range of characters. Note that the returned CString object may be empty.

    Parameters

    nCount

    The number of characters to extract from this CString object.

    Remarks

    Extracts the first (that is, leftmost) nCount characters from this CString object and returns a copy of the extracted substring. If nCount exceeds the string length, then the entire string is extracted. Left is similar to the Basic LEFT$ function (except that indexes are zero-based).

    For multibyte character sets (MBCS), nCount refers to each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two characters.

    Example

    The following example demonstrates the use of CString::Left.

    // example for CString::Left
    CString s( _T("abcdef") );
    ASSERT( s.Left(2) == _T("ab") );


    CString::Right

    CString::Right 

    CString Right( int nCount ) const; throw( CMemoryException );

    Return Value

    A CString object that contains a copy of the specified range of characters. Note that the returned CString object may be empty.

    Parameters

    nCount

    The number of characters to extract from this CString object.

    Remarks

    Extracts the last (that is, rightmost) nCount characters from this CString object and returns a copy of the extracted substring. If nCount exceeds the string length, then the entire string is extracted. Right is similar to the Basic RIGHT$ function (except that indexes are zero-based).

    For multibyte character sets (MBCS), nCount refers to each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two characters.

    Example

    The following example demonstrates the use of CString::Right.

    // example for CString::Right
    CString s( _T("abcdef") );
    ASSERT( s.Right(2) == _T("ef") );
    
     
  • 相关阅读:
    web前端开发面试被虐篇(一)
    JSON字符串 拼接与解析
    IntelliJ IDEA 2017 Dubbo Elastic-job Redis Zookeeper RabbitMQ FastDFS MyCat 简介以及部分实现(三)
    IntelliJ IDEA 2017 MySQL5 绿色版 Spring 4 Mybatis 3 配置步骤详解(二)
    IntelliJ IDEA 2017 JDK Tomcat Maven 配置步骤详解(一)
    简单练习
    C#实现上传/下载Excel文档
    javascript练习题
    转 浏览器滚动条以及常用样式汇总
    深入基础(五)工具模块,常用模块(2)
  • 原文地址:https://www.cnblogs.com/fwy-walking/p/4378975.html
Copyright © 2020-2023  润新知