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( 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") );
Cstring的使用的更多相关文章
- CString转换为LPSTR和LPSTR转化为CString
一.CString转换为LPSTR 方法一: CString strFileName LPSTR lpstr - strFileName.GetBuffer(); strFileName.Releas ...
- int与CString互相转化
int num; CString str; //int转CString num=; str.Format(_T("%d"),num); //CString转int str=L&qu ...
- (转)CString截取字符串全攻略
附:去掉空格方法 CString str("e w r we 中华ADF 华AG中"); newstr=str.Replace(" ", "&quo ...
- cstring to char *例子
Cstring m_strDescPath = ""; //类的成员变量 //"打开文件"对话框,选择文件,返回其路径 m_strDescPath = Boot ...
- CString转换为string
string CStringToString(CString strMFC) { CStringA strA; strA = strMFC.GetBuffer(); strMFC.ReleaseBuf ...
- VC++ CString类完美总结(整理)
CString 是编程中一种非常有用的数据类型,它是MFC中的一个类,很大程度上简化了MFC中的许多字符串的操作. CString位于头文件afx.h中. ①.CString 类对象的初始化: CSt ...
- Unicode字符集下CString与char *转换 (解决中文乱码等)(转)
UniCode 下 CString 转 char* 的方法的文章有很多,但是大部分都是在互相转载,看了那么多资料,仍然没有解决乱码的问题,后来从一个论坛的一条回复里面找到了正确的方法,特此拿出来与大家 ...
- CString std::string相互转换
CString->std::string 例子: CString strMfc=“test“; std::string strStl; strStl=strMfc.GetBuffer(0); s ...
- CString转string
如题,找了半天... //CString转string USES_CONVERSION; CString temp; temp = _T("kjdsaflkjdlfkj"); ch ...
- C++函数CString类常用函数
C++ STL库里有很多与字符串操作相关的函数,熟练应用STL,字符串的处理将变得轻松.自在. 字符串截取函数: 1.CString Left( int nCount ) const; //从左 ...
随机推荐
- sudo出现unable to resolve host
是因为/etc/hosts下的主机名和/etc/hostname下的主机名不一致所导致的错误,将两个改为一致即可
- Python序列——列表
列表是什么 1 创建列表 2 访问列表和更新列表 列表相关操作 内建函数对列表的支持 1 cmp 2 序列类型函数 列表内建函数 列表应用 1 堆栈 2 队列 1. 列表是什么 列表也是序列的一种.列 ...
- oracle查看锁表进程,杀掉锁表进程
查看锁表进程SQL语句1: select sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao ...
- break和continue 都是指的最接近的内层循环
break和continue 都是指的最接近的内层循环
- BZOJ-3439:Kpm的MC密码(Trie+DFS序+主席树)
背景 想Kpm当年为了防止别人随便进入他的MC,给他的PC设了各种奇怪的密码和验证问题(不要问我他是怎么设的...),于是乎,他现在理所当然地忘记了密码,只能来解答那些神奇的身份验证问题了... 描述 ...
- HihoCoder 1473 : 小Ho的强迫症( 欧几里得 )
描述 小Ho在一条笔直的街道上散步.街道上铺着长度为L的石板,所以每隔L距离就有一条石板连接的缝隙,如下图所示. 小Ho在散步的时候有奇怪的强迫症,他不希望脚踩在石板的缝隙上.(如果小Ho一只脚的脚尖 ...
- 洛谷 P3803 多项式乘法(FFT) —— FFT
题目:https://www.luogu.org/problemnew/show/P3803 终于学了FFT了! 参考博客:https://www.cnblogs.com/zwfymqz/p/8244 ...
- MSTAR SETBOX 常用API
HASHKEY: HashKey需要替换两个文件:“Customer_info.h”与“libecos.a” 1.MApi_DigiTuner_TPSGetLock() //判断是否有信号 2._Za ...
- Azure AD (6) 停止Azure AD Connect Sync同步,并删除自定义域名
<Windows Azure Platform 系列文章目录> 如果你已经了解了我之前写的文章:Azure AD (5) 在单一目录下,使用Azure AD单点登录 应该对使用Azure ...
- zynq交叉编译环境设置
环境准备 Vmware 虚拟机:ubuntu14.04 下载安装文件 环境设置 按照上面地址下载 xilinx-2011.09-50-arm-xilinx-linux-gnueabi.bin 将das ...