stderr, stdin, stdout

global variables for standard input/output streams 

Global Variables


#include <stdio.h>

extern FILE *stderr;

extern FILE *stdin;

extern FILE *stdout;


A file with associated buffering is called a stream and is declared to be a pointer to a defined type FILE. The fopen() function creates certain descriptive data for a stream and returns a pointer to designate the stream in all further transactions. Normally there are three open streams with constant pointers declared in the <stdio.h> header and associated with the standard open files.

At program startup three streams are predefined and need not be opened explicitly: standard input (for reading conventional input), standard output (for writing conventional output), and standard error (for writing diagnostic output). When opened the standard error stream is not fully buffered; the standard input and standard output streams are fully buffered if and only if the stream can be determined not to refer to an interactive device.

The following symbolic values in <unistd.h> define the file descriptors that is associated with the C-language stdin stdout and stderr when the application is started:


Standard input value stdin. Its value is 0.


Standard output value stdout. Its value is 1.


Standard error value stderr. Its value is 2.


POSIX.1 (1996)




PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


fclose(), feof(), ferror(), fgetc(), fgetpos(), fgets(), fgetwc(), fgetws(), fileno(), flockfile(), fopen(), fprintf(), fputc(), fputs(), fputwc(), fputws(), fread(), freopen(), fscanf(), fseek(), fsetpos(), ftrylockfile(), funlockfile(), getc(), getc_unlocked(), getchar(), getchar_unlocked(), gets(), getwc(), getwchar(), printf(), putc(), putc_unlocked(), putchar(), putchar_unlocked(), puts(), putwc(), putwchar(), scanf(), setbuf(), setvbuf(), ungetc(), ungetwc(), vfprintf(), vfscanf(), vprintf(), vscanf()

PTC MKS Toolkit 10.3 Documentation Build 39.