string用法收集
来源:互联网 发布:iphone6s网络支持 编辑:程序博客网 时间:2024/05/29 15:15
测试环境:Win10+VS2015
#include <string>#include <algorithm> // transform#include <functional> // not1、ptr_funint main(){ std::string text = " ADadoDS "; printf("text_len=[%02u] text=[%s]\n", text.length(), text.c_str()); // 删除text左端空格 text.erase(text.begin(), std::find_if(text.begin(), text.end(), std::not1(std::ptr_fun<int, int>(isspace)))); printf("text_len=[%02u] text=[%s]\n", text.length(), text.c_str()); // 删除text右端空格 text.erase(std::find_if( text.rbegin(), text.rend(), std::not1(std::ptr_fun<int, int>(isspace))).base(), text.end()); printf("text_len=[%02u] text=[%s]\n", text.length(), text.c_str()); // 字母转换为小写 std::transform(text.begin(), text.end(), text.begin(), tolower); printf("text_len=[%02u] text=[%s]\n", text.length(), text.c_str()); system("pause"); return 0;}
text_len=[14] text=[ ADadoDS ]
text_len=[11] text=[ADadoDS ]
text_len=[07] text=[ADadoDS]
text_len=[07] text=[adadods]
0 0
- string用法收集
- String-常见工具收集
- String用法
- string 用法
- string 用法
- string用法
- string用法
- string用法
- String用法
- String 用法
- String()用法
- string用法
- string用法
- string用法
- string用法
- String用法
- String用法
- ShellExecute 用法收集
- 我对文本模型的一些浅解(一)
- 自动配置VIM
- java int转string
- 谈谈C++中各种初始化方式
- Android签名
- string用法收集
- [C语言] C 语言学习代码
- myeclipse tomcat 远程调试
- Android学习笔记----跨进程调用Service(AIDL)
- 公网ip和内网ip
- 原创翻译:James Whittaker系列
- asp.net中 Server.Execute() Server.transfer()与Response.Redirect()的区别
- MySQL 去除字段中的换行和回车符(转)
- 安卓App热补丁动态修复技术介绍