CString::TrimLeft

void TrimLeft( );当在没有参数的情况下调用时,TrimLeft删除字符串最前面的换行符,空格和tab字符。

void CString::TrimLeft( TCHAR chTarget );

void CString::TrimLeft( LPCTSTR lpszTargets );

Parameters

chTarget

The target characters to be trimmed.

lpszTargets

A pointer to a string containing the target characters to be trimmed.

Remarks

Call the version of this member function with no parameters to trim leading whitespace characters from the string. When used with no parameters, TrimLeft removes newline, space, and tab characters.

Use the versions of this function that accept parameters to remove a particular character or a particular group of characters from the beginning of a string.

For more information, seeStrings Topics in Visual C++ Programmer’s Guide

Example

In this example, the string "\t\t   ****Hockey is best!" becomes "Hockey is best!":

CString strBefore;
CString strAfter;strBefore = _T("\t\t   ****Hockey is best!");
strAfter = strBefore;
strAfter.TrimLeft(T_("\t *"));用来将一个特定的字符或一群特定的字符从字符串的开始处删除。_tprintf(_T("Before: \"%s\"\n"), (LPCTSTR) strBefore);
_tprintf(_T("After : \"%s\"\n"), (LPCTSTR) strAfter);

CString::TrimRight


void TrimRight( );当在没有参数的情况下调用时,消除从右侧起所遇到的所有空格字符。void CString::TrimRight( TCHAR chTarget );void CString::TrimRight( LPCTSTR lpszTargets );ParameterschTargetThe target characters to be trimmed.lpszTargetsA pointer to a string containing the target characters to be trimmed.RemarksCall the version of this member function with no parameters to trim trailing whitespace characters from the string. When used with no parameters, TrimRight removes trailing newline, space, and tab characters from the string. Use the versions of this function that accept parameters to remove a particular character or a particular group of characters from the end of a string.Example
CString strBefore;
CString strAfter;strBefore = "Hockey is Best!!!!";strAfter = strBefore;str.TrimRight('!');printf("Before: \"%s\"\n", (LPCTSTR) strBefore);printf("After : \"%s\"\n\n", (LPCTSTR) strAfter);strBefore = "Hockey is Best?!?!?!?!";strAfter = strBefore;str.TrimRight("?!");消除目标字符集合中出现的任一字符,直到遇到第一个不属于目标字符串子集的字符为止。printf("Before: \"%s\"\n", (LPCTSTR) strBefore);printf("After : \"%s\"\n\n", (LPCTSTR) strAfter);
In the first example above, the string reading, "Hockey is Best!!!!" becomes "Hockey is Best".In the second example above, the string reading, , "Hockey is Best?!?!?!?!" becomes "Hockey is Best".

CString::TrimLeft和CString::TrimRight相关推荐

  1. CString Management (关于CString的所有操作)

    CString Management (关于CString的所有操作) 作者:FreeEIM CStrings are a useful data type. They greatly simplif ...

  2. cstring头文件(cstring头文件)

    头文件有什么样的作用呢? (eg.C++编译模式[1])从以上结构图来看,头文件是用户应用程序和函数库之间的桥梁和纽带 CStringW是什么啊?和CString有什么不同? CStringW是CSt ...

  3. 关于CString TrimLeft

    以前一直对TrimLeft()没有特别注意: 比如: CString str = "MR,RF"; str = str.TrimLeft("MR,"); 我们会 ...

  4. CString::trimleft()函数介绍:

    1.     CString   s   =   "0x0001";     s.TrimLeft("0x1");     AfxMessageBox(s); ...

  5. MFC中的CString.Format及CString,string,char*之间的转换

    1.CString.Format的使用:https://blog.csdn.net/wangkaishou/article/details/5846152 2.CString,string,char* ...

  6. CString::CompareNoCase与CString::Compare的区别

    函数原型:int CompareNoCase( LPCTSTR lpsz ) const; 返回值: 该函数对两个CString对象进行,如果内容完全一致则返回0:如果小于lpsz,则返回为-1:如果 ...

  7. CString::CompareNoCase与CString::Compare的区别 .

    函数原型:int CompareNoCase( LPCTSTR lpsz ) const; 返回值: 该函数对两个CString对象进行,如果内容完全一致则返回0:如果小于lpsz,则返回为-1:如果 ...

  8. CString::ReverseFind()和CString::Find()区别

    Find()是从左往右查找:ReverseFind()是从右边往左查找,但是他们返回的地址都是从左往右数的. 示例:[cpp] #include "stdafx.h" #inclu ...

  9. C、C++基础知识之 六 CString::ReverseFind()和CString::Find()区别

    CString::ReverseFind int ReverseFind( TCHAR ch ) const; 返回值: 参数: ch 要搜索的字符. 说明: 此成员函数在此 CString对象中搜索 ...

最新文章

  1. 腾讯8篇AI医疗论文入选国际学术顶会,涵盖癌症图像分类、CT病灶检测等领域...
  2. SAGE(SAGEMATH)密码学基本使用方法
  3. aws rds同步_将数据从Python同步到AWS RDS
  4. Invitation Cards POJ - 1511 SPFA(dijkstra+反向建图+邻接表(下标过大)+输入输出用stdio(iostream超时))
  5. 对于新安装的MySQL如何提升MySQL的安全级别
  6. 解决 CFBundleExecutable CFBundleSupportedPlatform错误
  7. GBase 8atmp 目录权限改变导致加载失败
  8. 一加手机怎么root权限_一加手机的两种ROOT权限获取教程详解
  9. mian函数传入参数
  10. 【优先队列】Toda 2
  11. 泛型中的 T、E、K、V,还记得嘛?
  12. 智能运维 | 我们不一样!告诉你百度云如何做智能流量异常检测
  13. 网线连接olt配置计算机IP,EPON-ONU-OLT配置手册.pdf
  14. python什么证书最有价值,python哪个证书含金量高
  15. windows 命令大全
  16. html5核显加速,英伟达:用GTX 16系列显卡加速,视频编辑速度达核显8倍
  17. 承接软硬件项目外包开发
  18. 菜根谭 全文 及译文
  19. 新概念英语1册71课
  20. 整型和短整型,有符号和无符号

热门文章

  1. 数据仓库之【用户行为数仓】01:项目效果展示、背景
  2. 【Apple App】解决苹果开发者网页加载慢问题
  3. linux wc -l效率,Linux wc命令详解
  4. 常用 sap 表 德语缩写 英汉注释
  5. 初中数学题目(实数)
  6. 【文本挖掘】业绩预告原因·其一
  7. matlab中label的意思,matlab中label函数
  8. 千亿级数仓项目(二)
  9. createnewfile() java_Java File createNewFile()方法
  10. 字体的样式及字体的分类