java/c++ How does output work? cout<< System.out.print
c++, java, linux
Solution
When the program gets executed, three special file descriptors: stdin, stdout and stderr are associated to some device to determine how input and output is managed. If you execute a program from a terminal shell, stdin is associated to the keyboard, stdout and stderr to the terminal window. When you execute the program in a development environment usually stdout and stderr are displayed in some special console tabs. In other situations the output goes to some log file or maybe get discarded...
System.out and cout are the objects representing the stdout stream in Java and C++.
Problem
I am mostly concerned with Linux but answers involving windows are welcome. When I use `System.out.println` or `cout<<` what is actually happening and what happens when I do a `cout` in a gui application (does it go anywhere)? One case that I am interested in is the Netbeans IDE. When I run a java program in Netbeans what makes it possible for the IDE to "steal" the output from the program and display it? Update/Sidenote http://www.linfo.org/standard_output.html One of the features of standard output is that it has a default destination but can easily be redirected (i.e., diverted) to another destination. That default destination is the display screen on the computer that initiated the program. Because the standard streams are plain text, they are by definition human readable. What is meant by "initiate the program"? I'm not very familiar with how the execution of a program begins but in the case of my netbeans example it's pretty clear that the IDE initiated the program. So what does that mean? When the program is being setup to be executed is there some meta data that is floating around letting the OS know that Netbeans is initiating the program?