What do you do when you clear spaces in std::string?

Asked 2 years ago, Updated 2 years ago, 67 views

What do you do when you clear spaces in std::string?

I just change it to a repeating sentence, but I wonder if I can do it without using a repeating sentence like a tupper().

c++ stl string

2022-09-21 18:14

1 Answers

Write remove_if" and isspace in <algorithm>. Additionally, <algorithm> cannot change the container by itself, so if you attach string::erase,

str.erase(remove_if(str.begin(), str.end(), isspace), str.end());


2022-09-21 18:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.