Standard C++ Library Reference ISO/IEC (VERSION3)
fgets
char *fgets(char *s, int n, FILE *stream);
The function reads characters from the input stream stream and stores them in successive
elements of the array beginning at s and continuing until it stores n-1 characters, stores an NL
character, or sets the end-of-file or error indicators. If fgets stores any characters, it concludes
by storing a null character in the next element of the array. It returns s if it stores any characters
and it has not set the error indicator for the stream; otherwise, it returns a null pointer. If it sets
the error indicator, the array contents are indeterminate.
FILE
typedef o-type FILE;
The type is an object type o-type that stores all control information for a stream. The
functions fopen and freopen allocate all FILE objects used by the read and write functions.
FILENAME_MAX
#define FILENAME_MAX <integer constant expression > 0>
The macro yields the maximum size array of characters that you must provide to hold a
filename.
fopen
FILE *fopen(const char *filename, const char *mode);
The function opens the file with the filename filename, associates it with a stream, and
returns a pointer to the object controlling the stream. If the open fails, it returns a null pointer.
The initial characters of mode determine how the program manipulates the stream and whether
it interprets the stream as text or binary. The initial characters must be one of the following
sequences:
"r" -- to open an existing text file for reading●
"w" -- to create a text file or to open and truncate an existing text file, for writing●
"a" -- to create a text file or to open an existing text file, for writing. The file-position
indicator is positioned at the end of the file before each write
●
"rb" -- to open an existing binary file for reading●
"wb" -- to create a binary file or to open and truncate an existing binary file, for writing●
"ab" -- to create a binary file or to open an existing binary file, for writing. The●