xref: /original-bsd/lib/libc/stdio/stdio.3 (revision abfc216a)
Copyright (c) 1990 Regents of the University of California.
All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.

@(#)stdio.3 6.4 (Berkeley) 03/05/91

STDIO 3 ""
C 4
NAME
stdio - standard buffered input/output package
SYNOPSIS
#include <stdio.h>

FILE *stdin;

FILE *stdout;

FILE *stderr;

DESCRIPTION
The functions described here constitute a user-level buffering scheme. The in-line macros getc (3) and putc (3) handle characters quickly. The higher level routines in stdio all use getc and putc ; they can be freely intermixed.

A file with associated buffering is called a stream , and is declared to be a pointer to a defined type FILE . Fopen (3) and funopen (3) create certain descriptive data for a stream and return a pointer to designate the stream in all further transactions. There are three normally open streams with constant pointers declared in the include file and associated with the standard open files:

10n stdin standard input file

.ns

stdout standard output file

.ns

stderr standard error file

A constant `pointer' NULL (0) designates no stream at all.

An integer constant EOF (-1) is returned upon end of file or error by integer functions that deal with streams.

Any routine that uses the standard input/output package must include the header file < stdio.h > . The constants and functions listed here are declared in the include file and need no further declaration. The following are implemented as macros; these names may not be reused without first removing their current definitions with #undef : BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_cuserid, L_tmpnam, NULL, SEEK_END, SEEK_SET, SEE_CUR, TMP_MAX, clearerr, feof, ferror, fileno, fropen, fwopen, getc, getchar, putc, putchar, stderr, stdin, stdout. Function versions of the macro functions feof, ferror, clearerr, fileno, getc, getchar, putc, and putchar exist and will be used if the macros definitions are explicitly removed.

Output streams that refer to terminal devices are always line buffered by default; pending output to such streams is written automatically whenever an input stream that refers to a terminal device is read. In cases where a large amount of computation is done after printing part of a line on an output terminal, it is necessary to fflush (3) the standard output before going off and computing so that the output will appear.

"SEE ALSO"
open(2), close(2), read(2), write(2)

all of the manual entries listed below

"RETURN VALUE"
The value EOF is returned uniformly to indicate that a FILE pointer has not been initialized with fopen , input (output) has been attempted on an output (input) stream, or a FILE pointer designates corrupt or otherwise unintelligible FILE data.
BUGS
The standard buffered functions do not interact well with certain other library and system functions, especially vfork and abort.
"LIST OF FUNCTIONS"
Name Appears on Page Description
clearerr ferror.3 stream status inquiries
fclose fclose.3 close a stream
fdopen fopen.3 open a stream
feof ferror.3 stream status inquiries
ferror ferror.3 stream status inquiries
fflush fflush.3 flush a stream
fgetc getc.3 get a character or word from a stream
fgetline fgetline.3 get a line from a stream
fgetpos fseek.3 reposition a stream
fgets fgets.3 get a line from a stream
fileno ferror.3 stream status inquiries
fmemopen fmemopen.3 open a block of memory as a stream
fopen fopen.3 open a stream
fprintf printf.3 formatted output conversion
fpurge fpurge.3 discard buffered stream data
fputc putc.3 put a character or word to a stream
fputs fputs.3 put a line to a stream
fread fread.3 stream binary input/output
freopen fopen.3 open a stream
fscanf scanf.3 formatted input conversion
fseek fseek.3 reposition a stream
fsetpos fseek.3 reposition a stream
ftell fseek.3 reposition a stream
funopen fopen.3 open a stream
fwrite fread.3 stream binary input/output
getc getc.3 get a character or word from a stream
getchar getc.3 get a character or word from a stream
gets fgets.3 get a line from a stream
getw getc.3 get a character or word from a stream
printf printf.3 formatted output conversion
putc putc.3 put a character or word to a stream
putchar putc.3 put a character or word to a stream
puts fputs.3 put a line to a stream
putw putc.3 put a character or word to a stream
remove remove.3 remove a file
rewind fseek.3 reposition a stream
scanf scanf.3 formatted input conversion
setbuf setvbuf.3 assign buffering to a stream
setbuffer setvbuf.3 assign buffering to a stream
setlinebuf setvbuf.3 assign buffering to a stream
setvbuf setvbuf.3 assign buffering to a stream
snprintf printf.3 formatted output conversion
sprintf printf.3 formatted output conversion
tmpfile tmpnam.3 create a temporary stream
tmpnam tmpnam.3 create a temporary file name
ungetc ungetc.3 push character back into input stream
vfprintf printf.3 formatted output conversion
vprintf printf.3 formatted output conversion
vsnprintf printf.3 formatted output conversion
vsprintf printf.3 formatted output conversion