fork download
  1. #include <iostream>
  2. #include <string> // forget about char[] and char*: use string instead !
  3. #include <algorithm> // for copy_if()
  4. #include <iterator> // for the back_inserter
  5. using namespace std;
  6.  
  7. struct PTPStatus{
  8. int stepsRemoved;
  9. }
  10.  
  11. string remove_extra_whitespaces(const string &input)
  12. {
  13. std::string output;
  14. unique_copy (input.begin(), input.end(), back_insert_iterator<string>(output), [](char a,char b){ return isspace(a) && isspace(b);});
  15. return output;
  16. }
  17.  
  18. PTPStatus getPTPStatus(){
  19. string result = "stepsRemoved 1";
  20. }
  21.  
  22. int main(int argc, char **argv)
  23. {
  24. string input = "stepsRemoved 1";
  25. string output = remove_extra_whitespaces(input);
  26.  
  27. cout<<output<<endl;
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
testing 2 ..
stepsRemoved 1