include problem
[unix-history] / .ref-BSD-3 / usr / doc / libNS / fopen.3
CommitLineData
0f4b110b
KS
1.TH FOPEN 3 4/8/79 3
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" or "w+"
43Create for concurrent read/write access.
44The file is first truncated, if it exists,
45and created if it does not.
46.ns
47.TP 5
48"a"
49Append: open for writing at end
50of file, or create for writing
51.ns
52.TP 5
53"ra" or "a+"
54Read and append: open for concurrent read/write access at end
55of file, or create file and open with such access
56.ns
57.TP 5
58"r+"
59Read and write: open for both reading and writing
60but do not truncate the file first.
61.PP
62.I Freopen
63substitutes the named file in place
64of the open
65.IR stream .
66It returns the original value of
67.IR stream .
68The original stream is closed.
69.PP
70.I Freopen
71is typically used to attach the preopened
72constant names,
73.B stdin, stdout, stderr,
74to specified files.
75.SH "SEE ALSO"
76open(2),
77fclose(3)
78.SH DIAGNOSTICS
79.I Fopen
80and
81.I freopen
82return the pointer
83.SM
84.B NULL
85if
86.I filename
87cannot be accessed.
88.SH BUGS
89The "+" syntax is included merely for compatibility with the USG
90stdio, and is not to be viewed as true support.
91The USG stdio has restrictions on how you can switch from reading
92to writing or vice versa.
93LibNS has no such restrictions, at a small runtime cost.