xref: /original-bsd/lib/libc/stdio/stdio.3 (revision 1afa398d)
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.3 (Berkeley) 01/20/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 : NULL , BUFSIZ , EOF , FOPEN_MAX , FILENAME_MAX , L_tmpnam , SEEK_SET , SEE_CUR , SEEK_END , TMP_MAX , stdin , stdout , stderr , fropen , fwopen , feof , ferror , clearerr , fileno , getc , getchar , putc , putchar , L_cuserid . 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 manuals 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 xxx
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
 smprintf printf.3 formatted output conversion
snprintf printf.3 formatted output conversion sprintf printf.3 formatted output conversion tmpfile xxx.3 xxx tmpnam xxx.3 xxx ungetc ungetc.3 push character back into input stream vfprintf printf.3 formatted output conversion vprintf printf.3 formatted output conversion vsmprintf printf.3 formatted output conversion
vsnprintf printf.3 formatted output conversion vsprintf printf.3 formatted output conversion
Although these have nothing to do with `standard I/O', the following declarations also appear in < stdio.h > as required by ANSI X3.159-1989 and IEEE 1003.2 standards:
Name Appears on Page Description
cuserid cuserid.3 xxx
getlogin getlogin.3 get login name
pclose popen.3 initiate I/O to/from a process
perror strerror.3 xxx
popen popen.3 initiate I/O to/from a process
remove remove.3 xxx
rename rename.2 xxx