fopen man page on NeXTSTEP

Man page or keyword search:  
man Server   1419 pages
apropos Keyword Search (all sections)
Output format
NeXTSTEP logo
[printable version]


FOPEN(3S)							     FOPEN(3S)

NAME
       fopen, freopen, fdopen - open a stream

SYNOPSIS
       #include <stdio.h>

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

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

       FILE *fdopen(int fildes, 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”  open for reading

       “w”  truncate to zero length or create for writing

       “a”  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.

       Type may also be followed by a “b” to denote a binary file, though this
       has no effect on this system.

       Freopen	substitutes  the  named	 file in place of the open stream.  It
       returns the original value of stream.  The original stream  is  closed.
       The type argument is used just as in the fopen function.

       Freopen	is  typically  used  to	 attach	 the preopened constant names,
       stdin, stdout, 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.  The meaning of the  type	 flag  is  exactly  as
       specified  for  fopen, except that “w” and “w+” do not cause truncation
       of the file.  The file  position	 indicator  associated	with  the  new
       stream  is  set to the position indicated by the file offset associated
       with the file descriptor.

RETURN VALUE
       If successful, fopen, freopen,  and  fdopen  returns  a	pointer	 to  a
       stream.	 Otherwise  a  NULL  pointer is returned if filename cannot be
       accessed, if too many files are already open,  or  if  other  resources
       needed cannot be allocated.

NOTES
       Fdopen is not portable to systems other than UNIX (and is neither ANSI-
       nor POSIX-compliant).

       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.

       The current directory is specified when	the  string  ""	 is  given  as
       filename.

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

SEE ALSO
       open(2), fclose(3S)

				August 1, 1992			     FOPEN(3S)
[top]

List of man pages available for NeXTSTEP

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net