I have this code to remove whitespace in a std::string and it removes all characters after the space. So if I have "abc def" it only returns "abc". How do I get it to go from "abc def ghi" to "abcdefghi"?
#include<iostream> #include<algorithm> #include<string> int main(int argc, char* argv[]) { std::string input, output; std::getline(std::cin, input); for(int i = 0; i < input.length(); i++) { if(input[i] == ' ') { continue; } else { output += input[i]; } } std::cout << output; std::cin.ignore(); }