Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Replace all spaces in a string in C++
#include <iostream> #include <cctype> // isalpha, isspace etc #include <string> std::string trim(const std::string& entry){ std::string trimmed; for(const auto &c: entry){ if(!isspace(c)) trimmed += c; } return trimmed; } int main() { std::cout << trim("Behre \n \t this \v and this too ") << std::endl; return 0; }
run
|
edit
|
history
|
help
0
bitfields_msvc
MSVC noexcept - works
VC++ windows exception
narrow_cast
C++ Macro overload
cv4_template
PreprocessorVsNamespace
Copy elision sample modern C++
Get parameter type
3