
------------------------------------------------------------------------------
6.6 Open a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fopen
[Syntax]
#include <stdio.h>
FILE *fopen( const char *filename, const char *mode ) ;
[Arguments]
filename Path name of a file.
mode Permitted access type.
[Return]
Returns a pointer to the opened file. If any error, returns NULL
pointer.
[Description]
Opens a file specified by "filename". Specify access type which is
requested to the file in "mode".
Type Meaning
-----------+-----------------------------------------------------
r Opens with Read-Only mode. Error if specified file
does not exist.
w Opens with output mode. Opens an empty file. Contents
of the existing file are destroyed.
a Opens with output mode, appending to the end of the
file. If specified file does not exist, creates it.
r+ Opens with both input and output mode. Specified file
must exist.
w+ Opens an empty file with both input and output mode.
Contents of the existing file are destroyed.
a+ Opens with both input and output. If no specified
file, creates it.
Addtionally, the following open mode can also be specified as
additional character in the above list.
Mode Meaning
-----------+-----------------------------------------------------
t Opens the file in text mode.(default)
In this mode, line feed characters are converted
as follows.
Input CR+LF --> LF
Output LF --> CR+LF
b Opens the file in binary mode.
In this mode, line feed characters are not converted.