0

I am working on a C++ program that can print output to more than one console. std::cout << value sends the value to console 1 (standard output) and std::cout2 << value sends the value to console 2. My OS is Linux and I am using Eclipse IDE.

This post and this show how this is down for a C++ application in Windows. How can I do this for my C++ code in Linux? I have a multi-threaded application, and I want each thread to print to its own console.

Clarification: Eclipse (like many other IDEs) has a console tab that shows you the standard output. Whatever you print to std::cout is shown in this console. I want to have a console2 tab so that I can selectively print to console or console2 in my C++ program.

enter image description here

Community
  • 1
  • 1
ManiAm
  • 1,759
  • 5
  • 24
  • 43
  • Likely, you ask about multiple terminal _windows_ (that is multiple terminal _emul;ators_), don't you? – user3159253 Apr 24 '16 at 05:51
  • Can you clarify what it is you mean by "console"? It's not clear from context. Do you mean the system's console terminals that you can access by hitting keys like `alt-F1`? – David Schwartz Apr 24 '16 at 05:52
  • Linux (and other unix-like systems) also has multiple text consoles (on a typical Linux system they are usually accessible via , ...) – user3159253 Apr 24 '16 at 05:53
  • Normally the shell "owns" the process and the process' output is displayed by the shell. But there's only one owner to a process. What you want is having "child"-consoles too for each you can just pipe the output to. The thing is, shell doesn't need a terminal-window to run. But in your scenario you probably want to open more terminal-windows or, if working on the tty, pipe to anothrr one. I yet don't think that this is good practice at all. Better log to a file and use tail+grep in combination to "split" the output. – ljrk Apr 24 '16 at 06:36
  • Create multiple console tabs in eclipse: http://stackoverflow.com/questions/7261151/in-eclipse-can-i-have-multiple-console-views-at-once-each-showing-a-different and use them with named pipes: http://www.tldp.org/LDP/lpg/node15.html – gavv Apr 24 '16 at 08:40

0 Answers0