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