fork(1) download
  1. #include <fstream>
  2. #include <string>
  3. #include <vector>
  4. #include <sstream>
  5. #include <cstdio>
  6.  
  7. constexpr std::size_t minfields{33};
  8.  
  9. std::vector<std::string> splitStr(const std::string& line, const char delimiter = ',')
  10. {
  11. std::vector<std::string> splitLine;
  12. splitLine.reserve(minfields);
  13. std::istringstream ss(line);
  14. std::string buf;
  15. while (std::getline(ss, buf, delimiter)) {
  16. splitLine.push_back(buf);
  17. }
  18. return splitLine;
  19. }
  20.  
  21. int main(int argc, char* argv[])
  22. {
  23. if(argc < 3)
  24. {
  25. exit(EXIT_SUCCESS);
  26. }
  27. std::ifstream inFile(argv[1]);
  28. FILE* outFile = fopen(argv[2], "w");
  29.  
  30. std::string line;
  31. while(std::getline(inFile,line))
  32. {
  33. auto split = splitStr(line, ';');
  34. if(split[3][0] == 'E' || split[3][0] == 'T')
  35. {
  36. fprintf(outFile, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
  37. split[0].c_str(),
  38. ",",
  39. split[1].c_str(),
  40. ",",
  41. split[3].c_str(),
  42. ",",
  43. split[4].c_str(),
  44. ",",
  45. split[5].c_str(),
  46. ",",
  47. split[6].c_str(),
  48. ",",
  49. split[10].c_str(),
  50. ",",
  51. split[9].c_str(),
  52. ",",
  53. split[11].c_str(),
  54. ",",
  55. split[7].c_str(),
  56. ",",
  57. split[32].c_str(),
  58. "\n");
  59. }
  60. }
  61. inFile.close();
  62. fclose(outFile);
  63. }
  64.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include <fstream>
^
Main.java:1: error: class, interface, or enum expected
#include <fstream>
         ^
Main.java:2: error: illegal character: '#'
#include <string>
^
Main.java:3: error: illegal character: '#'
#include <vector>
^
Main.java:4: error: illegal character: '#'
#include <sstream>
^
Main.java:5: error: illegal character: '#'
#include <cstdio>
^
Main.java:9: error: class, interface, or enum expected
std::vector<std::string> splitStr(const std::string& line, const char delimiter = ',')
^
Main.java:12: error: class, interface, or enum expected
    splitLine.reserve(minfields);
    ^
Main.java:13: error: class, interface, or enum expected
    std::istringstream ss(line);
    ^
Main.java:14: error: class, interface, or enum expected
    std::string buf;
    ^
Main.java:15: error: class, interface, or enum expected
    while (std::getline(ss, buf, delimiter)) {
    ^
Main.java:17: error: class, interface, or enum expected
    }
    ^
Main.java:19: error: class, interface, or enum expected
}
^
Main.java:26: error: class, interface, or enum expected
    }
    ^
Main.java:28: error: class, interface, or enum expected
    FILE* outFile = fopen(argv[2], "w");
    ^
Main.java:30: error: class, interface, or enum expected
    std::string line;
    ^
Main.java:31: error: class, interface, or enum expected
    while(std::getline(inFile,line))
    ^
Main.java:34: error: class, interface, or enum expected
        if(split[3][0] == 'E' || split[3][0] == 'T')
        ^
Main.java:59: error: class, interface, or enum expected
        }
        ^
Main.java:62: error: class, interface, or enum expected
    fclose(outFile);
    ^
Main.java:63: error: class, interface, or enum expected
}
^
21 errors
stdout
Standard output is empty