Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- libc - <b>fopen</b> http://www.ousob.com [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fopen
=====

Syntax
------

     #include <stdio.h>
     FILE *fopen(const char *filename, const char *mode);

Description
-----------

This function opens a stream corresponding to the named FILENAME with
the given MODE.  The mode can be one of the following:

`r'
     Open an existing file for reading.

`w'
     Create a new file (or truncate an existing file) and open it for
     writing.

`a'
     Open an existing file (or create a new one) for writing.  The file
     pointer is positioned to the end of the file before every write.

Followed by any of these characters:

`b'
     Force the file to be open in binary mode instead of the default
     mode.

     When called to open the console in binary mode, `fopen' will
     disable the generation of `SIGINT' when you press `Ctrl-C'
     (`Ctrl-Break' will still cause `SIGINT'), because many programs
     that use binary reads from the console will also want to get the
     `.characters.  You can use the `__djgpp_set_ctrl_c' library
     function (__djgpp_set_ctrl_c:.) if you want `Ctrl-C' to   
     generate interrupts while console is read in binary mode.

`t'
     Force the file to be open in text mode instead of the default mode.

`+'
     Open the file as with `O_RDWR' so that both reads and writes can
     be done to the same file.

If the file is open for both reading and writing, you must call
`fflush', `fseek', or `rewind' before switching from read to write or
from write to read.

The open file is set to line buffered if the underlying object is a
device (stdin, stdout, etc), or is fully buffered if the underlying
object is a disk file (data.c, etc).

If `b' or `t' is not specified in MODE, the file type is chosen by the
value of `fmode' (_fmode:.).   

Return Value
------------

A pointer to the `FILE' object, or `NULL' if there was an error.

Example
-------

     FILE *f = fopen("foo", "rb+"); /* open existing file for read/write, binary mode */


See Also: __djgpp_set_ctrl_c _fmode

Online resources provided by: http://www.ousob.com --- NG 2 HTML conversion by Dave Pearson