fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6.  
  7. int main()
  8. {
  9. using namespace std;
  10.  
  11. vector<string> input = {"1", "2", "", "", "3", "4" };
  12. vector<string> res;
  13.  
  14. copy_if(input.begin(), input.end(), back_inserter(res), [] (const string &s)
  15. {
  16. return ! s.empty();
  17. });
  18.  
  19. for (auto &s : res)
  20. {
  21. cout << s << endl;
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
1
2
3
4