zoukankan      html  css  js  c++  java
  • 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") );
    
     
  • 相关阅读:
    从 0 → 1,学习Linux该这么开始!
    Web和移动开发的未来
    css-div中文字过多(内容超出div宽度)后自动换行
    js+css--单选按钮,自定义选中的颜色???(性别按钮,男女)
    css-按钮中有图片和文字,怎么才能让文字和图片都中??
    js-点出弹框后(除了点击窗口上的叉子),点其他地方能够关闭窗口???
    css-外面元素的高度,由里面的元素进行撑开(由内部的高度决定)
    js-将传来的数据排序,让(全部)这个小按钮小圈圈,始终排列在最前面
    echart--如何在折线图上添加矩形背景(可以借用bar柱状图的实现效果)
    echart-如何将x轴和y轴的原点进行重合???
  • 原文地址:https://www.cnblogs.com/fwy-walking/p/4378975.html
Copyright © 2011-2022 走看看