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; //从左 ...
随机推荐
- Mongoose学习(1)
1.Schema : 一种以文件形式存储的数据库模型骨架,不具备数据库的操作能力 Model : 由Schema发布生成的模型,具有抽象属性和行为的数据库操作对 Entity : 由Mod ...
- 最大流EK算法
给定一个有向图G=(V,E),把图中的边看作 管道,每条边上有一个权值,表示该管道 的流量上限.给定源点s和汇点t,现在假设 在s处有一个水源,t处有一个蓄水池,问从 s到t的最大水流量是多少? 网络 ...
- vue中引入百度统计
vue作为单页面的,引入百度统计,需要注意不少. 一.基本的流量统计 在index.html 入口文件中引入百度统计生成的一连串代码: var _hmt = _hmt || []; (function ...
- 关于Linux启动文件rc.local的解惑
背景 首先,rc.local是Linux启动程序在login程序前执行的最后一个脚本,有的服务器中在rc.local中可能会有一句touch /var/lock/subsys/local,这是干什么的 ...
- codeforces 465C.No to Palindromes! 解题报告
题目链接:http://codeforces.com/problemset/problem/464/A 题目意思:给出一个长度为 n 且是 tolerable 的字符串s,需要求出字典序最小的长度也为 ...
- SpringMVC 注释@PathVariable
@PathVariable 是用来获得请求url中的动态参数的: @ResponseBody @RequestMapping(value="/pointUpload/{userid}&quo ...
- ACM2016级新生第三周训练赛
本次是弱校题解-比赛链接 备用链接 题目还是比较基础,比较简单.认真补题,学会学习. A -人见人爱A^B 题解: 求 A的B次方,我们可以用循环进行累乘操作,进而计算出次方.因为题目要求只需要求出最 ...
- Building Objective-C static libraries with categories(ObjC、all_load、force_load)
https://developer.apple.com/library/mac/qa/qa1490/_index.html 之所以使用该标志,和Objective-C的一个重要特性:类别(cat ...
- swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter.
'swprintf': swprintf has been changed to conform with the ISO C standard, adding an extra character ...
- Codeforces1111D Destroy the Colony 退背包+组合数
Codeforces1111D 退背包+组合数 D. Destroy the Colony Description: There is a colony of villains with severa ...