fork download
  1. #include <fstream>
  2. #include <sstream>
  3. #include <string>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. string strrev(const string& str)
  8. {
  9. string rev_str;
  10. for (int i=str.size()-1; i>=0; i--)
  11. rev_str += str[i];
  12. return rev_str;
  13. }
  14.  
  15. int main(int argc, char* argv[])
  16. {
  17. if (argc != 3)
  18. return 0;
  19.  
  20. ifstream ifs(argv[1]);
  21. ofstream ofs(argv[2]);
  22. string line;
  23. while (getline(ifs, line)) {
  24. line.erase(remove_if(line.begin(), line.end(),
  25. [](char c) { return c == '\r' || c == '\n'; }),
  26. line.end());
  27. ofs << strrev(line) << endl;
  28. }
  29. }
  30.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Standard output is empty