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 ...
Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.