Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mirror console output to file in c++

Tags:

c++

io

stdout

In C++, is there a smart way to mirror output from stdout to both the console and the file? I'm hoping there is a way to do it like in this question.

Edit: It would be nice to be able to do this with just the standard libraries (ie: no boost)..

like image 533
sFuller Avatar asked Mar 19 '12 02:03

sFuller


People also ask

How do I send console output to a file?

To redirect the output of a command to a file, type the command, specify the > or the >> operator, and then provide the path to a file you want to the output redirected to. For example, the ls command lists the files and folders in the current directory.

What is console WriteLine in C?

WriteLine(String, Object, Object) Writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information.

How do I create a C console application?

Open Visual Studio, and choose Create a new project in the Start window. In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.


1 Answers

Alternatively, just start your program so it's piped to the tee command.

like image 124
mpartel Avatar answered Oct 12 '22 07:10

mpartel