1

I use printf() in my C++ application to print some information when I run it from Linux command-line. Now, I am using output redirection (./main > output.txt) to save the results into file. I was wondering if it is possible to have both at the same time: see the result in command-line while the program is running, and do output redirection; without explicitly doing it by file I/O in C++.

Sahand Seifi
  • 225
  • 3
  • 11

1 Answers1

8

Do you need a solution in the program? Because if not, you can pipe the output into tee which takes its input and pumps in into both a file and stdout.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127