summaryrefslogtreecommitdiff
path: root/static/v10/man3/fopen.3
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-25 21:07:28 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-25 21:07:28 -0400
commit711594636704defae873be1a355a292505585afd (patch)
tree59ee13f863830d8beba6cfd02bbe813dd486c26f /static/v10/man3/fopen.3
parent3258a063c1f189d7b019e40e525b46bef9b9a7b1 (diff)
docs: Added UNIX V10 Manuals
Diffstat (limited to 'static/v10/man3/fopen.3')
-rw-r--r--static/v10/man3/fopen.3107
1 files changed, 107 insertions, 0 deletions
diff --git a/static/v10/man3/fopen.3 b/static/v10/man3/fopen.3
new file mode 100644
index 00000000..d8638862
--- /dev/null
+++ b/static/v10/man3/fopen.3
@@ -0,0 +1,107 @@
+.TH FOPEN 3S
+.CT 2 file_io
+.SH NAME
+fopen, freopen, fdopen, fclose, fflush \(mi open, close, or flush a stream
+.SH SYNOPSIS
+.nf
+.B #include <stdio.h>
+.PP
+.B FILE *fopen(filename, type)
+.B char *filename, *type;
+.PP
+.B FILE *freopen(filename, type, stream)
+.B char *filename, *type;
+.B FILE *stream;
+.PP
+.B FILE *fdopen(fildes, type)
+.B char *type;
+.PP
+.B int fclose(stream)
+.B FILE *stream;
+.PP
+.B int fflush(stream)
+.B FILE *stream;
+.fi
+.SH DESCRIPTION
+.I Fopen
+opens the file named by
+.I filename
+and associates a stream with it.
+.I Fopen
+returns a pointer to be used to identify
+the stream in subsequent operations.
+.PP
+.I Type
+is a character string having one of the following values:
+.nf
+.ta 8n
+\fL"r"\fP open for reading
+\fL"w"\fP create for writing
+\fL"r+w"\fP
+\fL"w+r"\fP open for reading and writing
+\fL"a"\fP append: open for writing at end of file, or create for writing
+.fi
+.PP
+.I Freopen
+substitutes the named file in place
+of the open
+.IR stream .
+It returns the original value of
+.IR stream .
+The original stream is closed.
+.I Freopen
+is typically used to attach the preopened
+constant names
+.LR stdin ,
+.L stdout
+and
+.L stderr
+to specified files.
+.PP
+.I Fdopen
+associates a stream with a file descriptor.
+The
+.I type
+of the stream must agree with the mode of the open file.
+.PP
+.I Fclose
+causes any buffers for the named
+.I stream
+to be emptied, and the file to be closed.
+Buffers allocated by the standard input/output system
+are freed.
+.PP
+.I Fclose
+is performed automatically upon
+calling
+.IR exit (3).
+.PP
+.I Fflush
+causes any buffered data for the named output
+.I stream
+to be written to that file.
+The stream remains open.
+.SH "SEE ALSO"
+.IR open (2),
+.IR popen (3),
+.IR stdio (3),
+.IR ferror (3)
+.SH DIAGNOSTICS
+.I Fopen
+and
+.I freopen
+return
+.B NULL
+if
+.I filename
+cannot be accessed.
+.PP
+.I Fclose
+and
+.I fflush
+return
+.B EOF
+if
+.I stream
+is not associated with a file, or
+if buffered data cannot be transferred to that file.