4.3BSD-Reno/share/man/cat3/fopen.0

Compare this file to the similar file:
Show the results in this format:




FOPEN(3)		      1989			 FOPEN(3)



NNAAMMEE
     fopen, freopen, fdopen - open a stream

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<ssttddiioo..hh>>

     FFIILLEE **ffooppeenn((ffiilleennaammee,, ttyyppee))
     cchhaarr **ffiilleennaammee,, **ttyyppee;;

     FFIILLEE **ffrreeooppeenn((ffiilleennaammee,, ttyyppee,, ssttrreeaamm))
     cchhaarr **ffiilleennaammee,, **ttyyppee;;
     FFIILLEE **ssttrreeaamm;;

     FFIILLEE **ffddooppeenn((ffiillddeess,, ttyyppee))
     cchhaarr **ttyyppee;;

DDEESSCCRRIIPPTTIIOONN
     _F_o_p_e_n opens the file named by _f_i_l_e_n_a_m_e and associates a
     stream with it.  _F_o_p_e_n returns a pointer to be used to iden-
     tify the stream in subsequent operations.

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

     "r"  open for reading

     "w"  create for writing

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

     In addition, each _t_y_p_e 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 trun-
     cates it, and "a+" positions it at the end.  Both reads and
     writes may be used on read/write streams, with the limita-
     tion that an _f_s_e_e_k, _r_e_w_i_n_d, or reading an end-of-file must
     be used between a read and a write or vice-versa.

     _F_r_e_o_p_e_n substitutes the named file in place of the open
     _s_t_r_e_a_m.  It returns the original value of _s_t_r_e_a_m.	The ori-
     ginal stream is closed.

     _F_r_e_o_p_e_n is typically used to attach the preopened constant
     names, ssttddiinn,, ssttddoouutt,, ssttddeerrrr,, to specified files.

     _F_d_o_p_e_n associates a stream with a file descriptor obtained
     from _o_p_e_n, _d_u_p, _c_r_e_a_t, or _p_i_p_e(2).  The _t_y_p_e of the stream
     must agree with the mode of the open file.

SSEEEE AALLSSOO
     open(2), fclose(3)



Printed 7/27/90               April				1






FOPEN(3)		      1989			 FOPEN(3)



DDIIAAGGNNOOSSTTIICCSS
     _F_o_p_e_n and _f_r_e_o_p_e_n return the pointer NNUULLLL if _f_i_l_e_n_a_m_e cannot
     be accessed, if too many files are already open, or if other
     resources needed cannot be allocated.

BBUUGGSS
     _F_d_o_p_e_n is not portable to systems other than UNIX.

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

     In order to support the same number of open files as does
     the system, _f_o_p_e_n must allocate additional memory for data
     structures using _c_a_l_l_o_c after 20 files have been opened.
     This confuses some programs which use their own memory allo-
     cators.  An undocumented routine, _f__p_r_e_a_l_l_o_c, may be called
     to force immediate allocation of all internal memory except
     for buffers.



































Printed 7/27/90               April				2