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") );
 

最新文章

  1. SSH私钥取消密码(passphrase )
  2. Maven学习笔记(1)之安装Maven
  3. KMP算法的详细解释及实现
  4. 分享一个批量导出当前实例下的所有linkedserver脚本
  5. 关于软件开发中兼容win7注册表的解决方案
  6. 09-排序2 Insert or Merge
  7. layer 弹出子页面然后给父页面赋值
  8. UVa 1585 - Score
  9. Linux下安装JRE
  10. postman传json串,以及postman官方文档
  11. 【ASP.NET MVC 牛刀小试】 URL Route
  12. 【读书笔记】【深入理解ES6】#6-Symbol和Symbol属性
  13. XXX系统项目分析
  14. MySQL主主同步配置
  15. 记一次CentOS5.7更新glibc导致libc.so.6失效,系统无法启动
  16. 导入javax.servlet。伺服登记无法解决:The import javax.servlet.MultipartConfigElement cannot be resolved
  17. error while loading shared libraries: libmysqlcppconn.so.7: cannot open shared object file: No such file or directory
  18. Docker 技巧:删除 Docker 所有镜像
  19. mysql中binlog_format的三种模式
  20. JSON教程

热门文章

  1. ZOJ - 3948 Marjar Cola 【循环】
  2. Vue的watch和computed属性
  3. CodeChef Forest Gathering —— 二分
  4. HDU4848 Wow! Such Conquering! —— dfs + 剪枝
  5. PHP执行外部命令【转】
  6. 检测SSL证书很好用的三个网站
  7. maven目录结构
  8. SVN 如何更换IP地址
  9. JS字符串与十六进制的相互转换(转载)
  10. 基于区域的全卷积神经网络(R-FCN)简介