title: C++ remove whitespace
body: <p>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"?</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;algorithm&gt;
  #include&lt;string&gt;
  
  int main(int argc, char* argv[]) {
      std::string input, output;
      std::getline(std::cin, input);
  
      for(int i = 0; i &lt; input.length(); i++) {
          if(input[i] == ' ') {
              continue;
          } else {
              output += input[i];
          }
      }
      std::cout &lt;&lt; output;
      std::cin.ignore();
  }
  </code></pre>