简体   繁体   中英

How to achieve partial output to cmd window and partial redirection to file for c++ program?

I know how to use pipe operator to redirect whole output of a c++ executable file(generated by my c++ code),but the question is that there are some contents that do not need to redirect to file, but to cmd window. In my limited experience with c++ programming, I guess there may be some kind of redirection method with higher priority than redirection pipe operator, but I've tried multiple variations of this, but none of them seem to work. Any ideas?

Use std::cout for things that you want to redirect to the file, and std::cerr for things that you want to print to the command window. Normal redirection with > and |only affects the former.

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