BSD 2 development
[unix-history] / man / fopen.u
CommitLineData
d38390b9
BJ
1.TH FOPEN UCB 4/8/79
2.SH NAME
3fopen, freopen \- open a stream
4.SH SYNOPSIS
5.B #include <nstdio.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.SH DESCRIPTION
23.I Fopen
24opens the file named by
25.I filename
26and associates a stream with it.
27.I Fopen
28returns a pointer to be used to identify
29the stream in subsequent operations.
30.PP
31.I Type
32is a character string having one of the following values:
33.TP 5
34"r"
35open for reading
36.ns
37.TP 5
38"w"
39create for writing
40.ns
41.TP 5
42"rw"
43create for concurrent read/write access
44.ns
45.TP 5
46"a"
47append: open for writing at end
48of file, or create for writing
49.ns
50.TP 5
51"ra"
52read and append: open for concurrent read/write access at end
53of file, or create file and open with such access
54.PP
55.I Freopen
56substitutes the named file in place
57of the open
58.IR stream .
59It returns the original value of
60.IR stream .
61The original stream is closed.
62.PP
63.I Freopen
64is typically used to attach the preopened
65constant names,
66.B stdin, stdout, stderr,
67to specified files.
68.SH "SEE ALSO"
69open(2),
70fclose(3)
71.SH DIAGNOSTICS
72.I Fopen
73and
74.I freopen
75return the pointer
76.SM
77.B NULL
78if
79.I filename
80cannot be accessed.
81.SH BUGS
82Undoubtedly