stdio(3) Library Functions Manual stdio(3) stdio - - C (libc, -lc) #include extern FILE *stdin; extern FILE *stdout; extern FILE *stderr; - -. , - . ; . A stream is associated with an external file (which may be a physical device) by opening a file, which may involve creating a new file. Creating an existing file causes its former contents to be discarded. If a file can support positioning requests (such as a disk file, as opposed to a terminal), then a file position indicator associated with the stream is positioned at the start of the file (byte zero), unless the file is opened with append mode. If append mode is used, it is unspecified whether the position indicator will be placed at the start or the end of the file. The position indicator is maintained by subsequent reads, writes, and positioning requests. All input occurs as if the characters were read by successive calls to the fgetc(3) function; all output takes place as if all characters were written by successive calls to the fputc(3) function. A file is disassociated from a stream by closing the file. Output streams are flushed (any unwritten buffer contents are transferred to the host environment) before the stream is disassociated from the file. The value of a pointer to a FILE object is indeterminate after a file is closed (garbage). A file may be subsequently reopened, by the same or another program execution, and its contents reclaimed or modified (if it can be repositioned at the start). If the main function returns to its original caller, or the exit(3) function is called, all open files are closed (hence all output streams are flushed) before program termination. Other methods of program termination, such as abort(3) do not bother about closing files properly. , : (standard input) ( ), (standard output) ( ) (standard error) ( ). : stdin, stdout stderr. , ; , - . , , ; , . , , fflush(3), . The stdio library is a part of the library libc and routines are automatically loaded as needed by cc(1). The SYNOPSIS sections of the following manual pages indicate which include files are to be used, what the compiler declaration for the function looks like, and which external variables are of interest. ; #undef: BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_cuserid, L_ctermid, L_tmpnam, NULL, SEEK_END, SEEK_SET, SEEK_CUR, TMP_MAX, clearerr, feof, ferror, fileno, getc, getchar, putc, putchar, stderr, stdin, stdout. feof, ferror, clearerr, fileno, getc, getchar, putc, putchar , . ------------------------------------------------------------------------ clearerr(3) fclose(3) fdopen(3) feof(3) ferror(3) fflush(3) fgetc(3) fgetpos(3) fgets(3) fileno(3) fmemopen(3) open memory as stream fopen(3) fopencookie(3) open a custom stream fprintf(3) fpurge(3) fputc(3) fputs(3) fread(3) - freopen(3) fscanf(3) fseek(3) fsetpos(3) ftell(3) fwrite(3) - getc(3) getchar(3) gets(3) getw(3) mktemp(3) () open_memstream(3) open a dynamic memory buffer stream open_wmemstream(3) open a dynamic memory buffer stream perror(3) printf(3) putc(3) putchar(3) puts(3) putw(3) remove(3) rewind(3) scanf(3) setbuf(3) setbuffer(3) setlinebuf(3) setvbuf(3) sprintf(3) sscanf(3) strerror(3) sys_errlist(3) sys_nerr(3) tempnam(3) tmpfile(3) tmpnam(3) ungetc(3) vfprintf(3) vfscanf(3) vprintf(3) vscanf(3) vsprintf(3) vsscanf(3) C11, POSIX.1-2008. C89, POSIX.1-2001. close(2), open(2), read(2), write(2), stdout(3), unlocked_stdio(3) () Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () . Linux man-pages 6.18 21 2025 . stdio(3)