c++ 去除字符串中的空格和标点符号 (remove_if 函数的用法)
2016-03-07 04:23
447 查看
C++中提供了自动删除空格和标点符号的函数,使用如下:
注意需要包含如上两个头文件
#include <ctype.h> #include <algorithm> str_testing.erase( remove_if ( str_testing.begin(), str_testing.end(), static_cast<int(*)(int)>(&ispunct) ), str_testing.end()); str_testing.erase( remove_if ( str_testing.begin(), str_testing.end(), static_cast<int(*)(int)>(&isspace) ), str_testing.end());
注意需要包含如上两个头文件
相关文章推荐
- 实习季C++基本问题汇总
- C/C++内存分布与变量初始化顺序
- 操作系统用C语言模拟基于时间片进程调度程序
- 《Effective C++》学习笔记——条款41
- LeetCode 5 : Longest Palindromic Substring(C++)
- LeetCode 4 : Median of Two Sorted Arrays ( C++ )
- LeetCode 7 Reverse Integer ( C++ )
- LeetCode 6. ZigZag Conversion ( C++ )
- C++11: std::thread和std::this_thread
- 简单记事本和简单四则运算计算器源代码(*.h *.cpp main.cpp)
- STL iterator失效
- C语言学习备忘
- C语言学习备忘
- C语言学习备忘
- C语言学习备忘
- C语言学习备忘
- C语言学习备忘
- C语言学习备忘
- C语言学习备忘
- C语言学习备忘