14.11 IN THE DAYS OF C
Since C++ is the superset of C, facilities present in C language can be used directly in C++ programs. Many times we have to maintain code written few years ago. Hence, it will be in order to have a brief introduction to file handling in C language.
C uses structure named FILE to hold information regarding a file. It has defined structure “FILE” with following definition.
typedef struct { short level; unsigned flags; char fd; unsigned char hold; short bsize; unsigned char *buffer, *curp; unsigned istemp; short token; } FILE;
To open a file function fopen() has to be used. It has the following syntax:
FILE *fopen(const char *filename, const char *mode);
Mode string ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access