fork(13) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. int main() {
  6. std::string str = " ";
  7. std::cout << str << "<-" << std::endl;
  8.  
  9. size_t endpos = str.find_last_not_of(" \t");
  10. size_t startpos = str.find_first_not_of(" \t");
  11. if( std::string::npos != endpos )
  12. {
  13. str = str.substr( 0, endpos+1 );
  14. str = str.substr( startpos );
  15. }
  16. else{
  17. str.erase(std::remove(std::begin(str), std::end(str), ' '), std::end(str));
  18. }
  19.  
  20. std::cout << str << "<-";
  21. return 0;
  22. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
		                 <-
		<-