cout always writes to the standard output stream (
stdout). If you want the output to be redirected elsewhere (e.g. a graphical window) you will have to pipe the output to another program or thread responsible for handling the graphical interface. There are many ways this can be done but it depends on the operating system somewhat.
By default, on Linux you can observe the stdout of both console and graphical programs just by running it from a terminal. In fact, there's really no clear-cut distinction between "console" and "graphical" programs in Linux.
On Windows it's rather different: console and graphical programs are distinct*. Graphical programs do not have a terminal allocated by default, so stdout messages usually end up in oblivion. There is a little bit of trickery required to allocate a terminal for graphical programs (so that they behave similar to Linux).
(I can't comment on Macs as I don't use them.)
You can do redirections externally via the shell. Here I assume a Bourne-like shell.** Say you want to run a program
my-simulation and feed its output to another program
my-display, which presumably reads from the standard input (
stdin). If you run the program as is, the output will be dumped into the terminal as usual:
You can establish a pipe by running the following in the shell:
./my-simulation | ./my-display
Or if you want to write to a file instead,
Of course, these can all be done in C/C++, but with more work. If you want
stdout to be redirected to a file, you can use freopen from the standard library. Redirecting
stdout to another process is slightly more difficult as you need to use platform-specific API to deal with processes and piping file descriptors.
[*] In Windows lingo, graphical programs are called Windows applications. You can find more about the various differences between these two kinds of programs on the MSDN.
[**] You can also do something similar with Command Prompt on Windows, but with a slightly different syntax.