Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)

fclose(3s)



FOPEN(3S)               COMMAND REFERENCE               FOPEN(3S)



NAME
     fopen, freopen, fdopen - open a stream

SYNOPSIS
     #include <stdio.h>

     FILE *fopen(filename, type)
     char *filename, *type;

     FILE *freopen(filename, type, stream)
     char *filename, *type;
     FILE *stream;

     FILE *fdopen(fildes, type)
     char *type;

DESCRIPTION
     Fopen opens the file named by filename and associates a
     stream with it.  Fopen returns a pointer to be used to
     identify the stream in subsequent operations.

     Type is a character string having one of the following
     values:

          r    means open for reading

          w    means create for writing

          a    means append: open for writing at end of file, or
               create for writing

     In addition, each type may be followed by a + to have the
     file opened for reading and writing.  r+ positions the
     stream at the beginning of the file, w+ creates or truncates
     it, and a+ positions it at the end.  Both reads and writes
     may be used on read/write streams, with the limitation that
     an fseek, rewind, or reading an end-of-file must be used
     between a read and a write or vice-versa.

     Freopen substitutes the named file in place of the open
     stream.  It returns the original value of stream.  The
     original stream is closed.

     Freopen is typically used to attach the preopened constant
     names, stdin, stdout, and stderr, to specified files.

     Fdopen associates a stream with a file descriptor obtained
     from open, dup, creat, or pipe(2). The type of the stream
     must agree with the mode of the open file.

DIAGNOSTICS
     Fopen and freopen return the pointer NULL if filename cannot



Printed 3/13/89                                                 1





FOPEN(3S)               COMMAND REFERENCE               FOPEN(3S)



     be accessed.

CAVEATS
     Fdopen is not portable to systems other than UTek.

     The read/write types do not exist on all systems.  Those
     systems without read/write modes will probably treat the
     type as if the + was not present.  These are unreliable in
     any event.

SEE ALSO
     open(2), and fclose(3s).











































Printed 3/13/89                                                 2



%%index%%
na:288,90;
sy:378,1937;
de:2315,2753;
di:5068,324;5752,19;
ca:5771,608;
se:6379,175;
%%index%%000000000118

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026