Read stdout from another console application

Is it possible to get stdout data from another console application?

Or, run two consoles from one c++ program?
Is it possible to get stdout data from another console application?

Yes. It's called a pipe. From the command line you do it like this:
prog1 | prog2 | prog3

Here prog1's stdout (or cout) becomes prog2's stdin (or cin). And prog2's stdout/cout become prog3's stdout/cout. It's one of the really cool inventions of UNIX.
Can you explain more on how this works? And does this work on Windows?
Start a command prompt and type
dir \windows | more

This will execute the dir \windows command which displays the very large \windows directory. It sends the output to the input of the program more which displays a screenful of information and then pauses waiting for you to press the space bar.
Topic archived. No new replies allowed.