简体   繁体   中英

Copying (not redirecting) Visual C++ console output to text file while still viewing the output in console window

a variety on this question has been asked and answered https://stackoverflow.com/a/21709463/3906864

I followed the above linked answer and did the following

">log.txt"

that argument was added here

在此处输入图片说明

This allows the console output to be redirected from console to file, and the console window remains blank without anything displayed in it.

but i can't find a way to view the output in console while still simultaneously saving a copy to a txt file. any ideas ?

you need a version of tee . Powershell has Tee-Object ( https://technet.microsoft.com/en-us/library/hh849937.aspx )

An example from link

get-process | tee-object -filepath C:\Test1\testfile2.txt

The above will output both to terminal and to the file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM