Talking to the terminal

Under DOS, or other text based systems, there is only one way in and one way out. Under Linux and every Unix system, there is one way in but two ways out.

The terminal has 2 outputs, one for standard output and one for errors. By default, they both display on the same device: your monitor. But they can be redirected, for example, to different logs. This is why it's important for you to use them properly.

The standard output is called stdout, and printing to it will print to the screen, or where it is redirected. In C, it may look like this:

fprintf(stdout, "Test\n"); The standard error is called stderr: fprintf(stderr, "Error\n");

To input, you need to read from the standard input, called stdin. They are all available to you from the stdio.h file.