|
|
1.1 root 1: .TH FOPEN 3S
2: .CT 2 file_io
3: .SH NAME
4: fopen, freopen, fdopen, fclose, fflush \(mi open, close, or flush a stream
5: .SH SYNOPSIS
6: .nf
7: .B #include <stdio.h>
8: .PP
9: .B FILE *fopen(filename, type)
10: .B char *filename, *type;
11: .PP
12: .B FILE *freopen(filename, type, stream)
13: .B char *filename, *type;
14: .B FILE *stream;
15: .PP
16: .B FILE *fdopen(fildes, type)
17: .B char *type;
18: .PP
19: .B int fclose(stream)
20: .B FILE *stream;
21: .PP
22: .B int fflush(stream)
23: .B FILE *stream;
24: .fi
25: .SH DESCRIPTION
26: .I Fopen
27: opens the file named by
28: .I filename
29: and associates a stream with it.
30: .I Fopen
31: returns a pointer to be used to identify
32: the stream in subsequent operations.
33: .PP
34: .I Type
35: is a character string having one of the following values:
36: .nf
37: .ta 8n
38: \fL"r"\fP open for reading
39: \fL"w"\fP create for writing
40: \fL"r+w"\fP
41: \fL"w+r"\fP open for reading and writing
42: \fL"a"\fP append: open for writing at end of file, or create for writing
43: .fi
44: .PP
45: .I Freopen
46: substitutes the named file in place
47: of the open
48: .IR stream .
49: It returns the original value of
50: .IR stream .
51: The original stream is closed.
52: .I Freopen
53: is typically used to attach the preopened
54: constant names
55: .LR stdin ,
56: .L stdout
57: and
58: .L stderr
59: to specified files.
60: .PP
61: .I Fdopen
62: associates a stream with a file descriptor.
63: The
64: .I type
65: of the stream must agree with the mode of the open file.
66: .PP
67: .I Fclose
68: causes any buffers for the named
69: .I stream
70: to be emptied, and the file to be closed.
71: Buffers allocated by the standard input/output system
72: are freed.
73: .PP
74: .I Fclose
75: is performed automatically upon
76: calling
77: .IR exit (3).
78: .PP
79: .I Fflush
80: causes any buffered data for the named output
81: .I stream
82: to be written to that file.
83: The stream remains open.
84: .SH "SEE ALSO"
85: .IR open (2),
86: .IR popen (3),
87: .IR stdio (3),
88: .IR ferror (3)
89: .SH DIAGNOSTICS
90: .I Fopen
91: and
92: .I freopen
93: return
94: .B NULL
95: if
96: .I filename
97: cannot be accessed.
98: .PP
99: .I Fclose
100: and
101: .I fflush
102: return
103: .B EOF
104: if
105: .I stream
106: is not associated with a file, or
107: if buffered data cannot be transferred to that file.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.