c++ - 从句子中删除给定字符的 C++ 程序不起作用
问题描述
该程序只是从第一个单词中删除字符,而不是从所有句子中删除字符。我该如何解决?我需要从句子中删除所有字符,而不仅仅是第一个世界。谢谢。
#include <iostream>
#include <string>
#include <algorithm>
int main()
{
std::string s;
char c;
std::cout << "Enter the string : ";
std::cin >> s;
std::cout << "\nEnter the character : ";
std::cin >> c;
/* Removing character c from s */
s.erase(std::remove(s.begin(), s.end(), c), s.end());
std::cout << "\nString after removing the character "
<< c << " : " << s;
}
解决方案
推荐阅读
- sql - 关于 Oracle PURGE INDEX 语句
- angular - 如何允许服务在 Angular 5 测试中进行真正的 http 调用
- python - Numpy power 不允许负值
- apache - .htaccess RewriteRule 没有重定向到正确的位置
- javascript - 表单提交时停止页面重定向
- c# - 使用 C# .NET 批量转换文件
- c# - 如何在开始 xUnit 测试之前调出 docker-compose 中指定的容器?
- wso2-am - WSO2 APIM 工作流 EI 或者 BPS?
- c - 为在 C 中转换为字符串的 int 数组动态分配内存
- ios - 如何在 iOS 上重现带有火花的 watchOS 关闭活动环动画?