xtd 0.2.0
redirect_output.cpp

Shows how to use xtd::console class.

#include <xtd/io/path>
#include <xtd/io/file>
#include <xtd/console>
#include <xtd/environment>
using namespace xtd;
using namespace xtd::io;
auto main()->int {
auto output_file_path = path::combine(path::get_temp_path(), "xtd_example_write.txt");
auto output_stream = file::open_write(output_file_path);
console::set_out(output_stream);
output_stream.close();
file::remove(output_file_path);
}
// This code can produce the following output:
//
// Item1
// Item2
// Item3