Annotation of cci/usr/src/man/man3/fopen.3s, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.