The following code redirects stdout to the write-end of a pipe, whose read-end I then read from.
stdout
// main.cpp #include #include &l