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());
注意需要包含如上两个头文件
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。