#include "stdin_to_file.hh" #include #include long int stdin_to_file(const std::string& filename) { std::ofstream file_out; std::string token; // trying to open output file "data.out" file_out.open(filename); size_t res = 0; // Read until eof or an error occurs while (std::cin >> token) { res++; file_out << token << '\n'; } // stream is closed at the end of the scope return res; }