source: trunk/minix/man/man3/fopen.3@ 12

Last change on this file since 12 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 2.3 KB
Line 
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)fopen.3s 6.3 (Berkeley) 5/27/86
6.\"
7.TH FOPEN 3 "May 27, 1986"
8.UC 4
9.SH NAME
10fopen, freopen, fdopen \- open a stream
11.SH SYNOPSIS
12.nf
13.ft B
14#include <stdio.h>
15
16FILE *fopen(const char *\fIfilename\fP, const char *\fItype\fP)
17FILE *freopen(const char *\fIfilename\fP, const char *\fItype\fP, FILE *\fIstream\fP)
18FILE *fdopen(int \fIfildes\fP, const char *\fItype\fP)
19.ft R
20.fi
21.SH DESCRIPTION
22.B Fopen
23opens the file named by
24.I filename
25and associates a stream with it.
26.B Fopen
27returns a pointer to be used to identify the stream in subsequent operations.
28.PP
29.I Type
30is a character string having one of the following values:
31.TP 5
32"r"
33open for reading
34.ns
35.TP 5
36"w"
37create for writing
38.ns
39.TP 5
40"a"
41append: open for writing at end of file, or create for writing
42.PP
43In addition, each
44.I type
45may be followed by a "+" to have the file opened for reading and writing.
46"r+" positions the stream at the beginning of the file, "w+" creates
47or truncates it, and "a+" positions it at the end. Both reads and writes
48may be used on read/write streams, with the limitation that an
49.BR fseek ,
50.BR rewind ,
51or reading an end-of-file must be used between a read and a write or vice-versa.
52.PP
53.B Freopen
54substitutes the named file in place of the open
55.IR stream .
56It returns the original value of
57.IR stream .
58The original stream is closed.
59.PP
60.B Freopen
61is typically used to attach the preopened constant names,
62.B stdin, stdout, stderr,
63to specified files.
64.PP
65.B Fdopen
66associates a stream with a file descriptor obtained from
67.BR open ,
68.BR dup ,
69.BR creat ,
70or
71.BR pipe (2).
72The
73.I type
74of the stream must agree with the mode of the open file.
75.SH "SEE ALSO"
76.BR open (2),
77.BR fclose (3).
78.SH DIAGNOSTICS
79.B Fopen
80and
81.B freopen
82return the pointer
83.SM
84.B NULL
85if
86.I filename
87cannot be accessed,
88if too many files are already open,
89or if other resources needed cannot be allocated.
90.SH BUGS
91.B Fdopen
92is not portable to systems other than UNIX.
93.PP
94The read/write
95.I types
96do not exist on all systems. Those systems without
97read/write modes will probably treat the
98.I type
99as if the "+" was not present. These are unreliable in any event.
Note: See TracBrowser for help on using the repository browser.