64,849
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
int main(void)
{
string str = "sdijf\njosdf\njdf";
cout << str << endl;
str.erase(remove(str.begin(), str.end(), '\n'), str.end());
cout << str << endl;
return 0;
}
void removeendl(string &s)
{
while(1)
{
string::iterator it = find(s.begin(), s.end(), '\n');
if(it == s.end())
{
break;
}
s.erase(it);
}
}