Bell 32V release
[unix-history] / usr / man / man3 / fopen.3s
CommitLineData
c4665c80
TL
1.TH FOPEN 3S
2.SH NAME
3fopen, freopen, fdopen \- open a stream
4.SH SYNOPSIS
5.B #include <stdio.h>
6.PP
7.SM
8.B FILE
9.B *fopen(filename, type)
10.br
11.B char *filename, *type;
12.PP
13.SM
14.B FILE
15.B *freopen(filename, type, stream)
16.br
17.B char *filename, *type;
18.br
19.SM
20.B FILE
21.B *stream;
22.PP
23.SM
24.B FILE
25.B *fdopen(fildes, type)
26.br
27.B char *type;
28.SH DESCRIPTION
29.I Fopen
30opens the file named by
31.I filename
32and associates a stream with it.
33.I Fopen
34returns a pointer to be used to identify
35the stream in subsequent operations.
36.PP
37.I Type
38is a character string having one of the following values:
39.TP 5
40"r"
41open for reading
42.ns
43.TP 5
44"w"
45create for writing
46.ns
47.TP 5
48"a"
49append: open for writing at end
50of file, or create for writing
51.PP
52.I Freopen
53substitutes the named file in place
54of the open
55.IR stream .
56It returns the original value of
57.IR stream .
58The original stream is closed.
59.PP
60.I Freopen
61is typically used to attach the preopened
62constant names,
63.B stdin, stdout, stderr,
64to specified files.
65.PP
66.I Fdopen
67associates a stream with a file descriptor obtained from
68.I open, dup, creat,
69or
70.IR pipe (2).
71The
72.I type
73of the stream must agree with the mode of the open file.
74.SH "SEE ALSO"
75open(2),
76fclose(3)
77.SH DIAGNOSTICS
78.I Fopen
79and
80.I freopen
81return the pointer
82.SM
83.B NULL
84if
85.I filename
86cannot be accessed.
87.SH BUGS
88.I Fdopen
89is not portable to systems other than UNIX.