惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
月光博客
月光博客
Y
Y Combinator Blog
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
美团技术团队
T
Tailwind CSS Blog
小众软件
小众软件
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
G
Google Developers Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements
The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 希冀

令人讨厌的CLOSE_WAIT状态的生成原因 令人头痛的字符集问题 原创:运用ifstream的getline时需要注意的问题 Linux 系统的单用户模式、修复模式、跨控制台登录在系统修复中的运用 linux命令知多少(不断更新中......) linux内存管理--top下信息的分析【转帖】 转: 用”堆栈区数据复制”理解Java赋值和参数传递机制的心得 SNMP 资料搜集 linux shell 检查进程PID linux/unix 下 vi 的用法. 使用const 提高函数的健壮性 [转]Install ACE in Linux (摘)Who are the best programmers? 初识vi和python 学习札记四:操作符(&,∧,| 与 &&,||) 学习札记三:数据类型 学习札记二:格式项的语法{index[,alignment][:formatString]} (补) 学习札记一:格式项的语法{index[,alignment][:formatString]} 走上.NET征程
C++中如何去掉std::string对象的首尾空格
希冀 · 2006-11-14 · via 博客园 - 希冀

/***********write by myself***********/
/***********begin test file***********/
#include <iostream>
#include <string>

int main()
{
 std::string str1 = "   hello world!   ";
 std::string trimstring = " ";
 std::cout << "str = \"" << str1 << "\"" << std::endl;
 std::cout << "str.find_first_of(' ')     : " << str1.find_first_of(trimstring)     << std::endl;
 std::cout << "str.find_first_not_of(' ') : " << str1.find_first_not_of(trimstring) << std::endl;
 std::cout << "str.find_last_of(' ')     : " << str1.find_last_of(trimstring)      << std::endl;
 std::cout << "str.find_last_not_of(' ')  : " << str1.find_last_not_of(trimstring)  << std::endl;
 str1.erase(str1.find_last_not_of(trimstring)+1);
 std::cout << "after right trim : \"" << str1 << "\"" << std::endl;
 str1.erase(0,str1.find_first_not_of(trimstring));
 std::cout << "after left trim  : \"" << str1 << "\"" << std::endl;
 return 0;
}
/***********end test file***********/