Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #274 Remove all white space characters

Create the string t from the string s, removing all the spaces, newlines, tabulations, etc.

#include <iostream>
#include <string>
#include <algorithm>
auto t = s;
t.erase(std::ranges::remove_if(t, [](const char c) { return std::isspace(c); }).begin(),t.end()) ;

New implementation...