Advertisement



< Prev



C++ I/O Array of Objects






In our last few article, we have explained how to use the binary input/output read() and write() functions to read and write an object from/to a file on the disk. In this tutorial, we are going to explain how to read and write an array of objects from/to a file on disk, by using the same binary input/output read() and write() functions.

Binary I/O Functions Description
read()
This binary function is used to perform file input operation i.e. to read the objects stored in a file.

write
This binary function is used to perform file output operation i.e. to write the objects to a file, which is stored in the computer memory in a binary form.

Only the data member of an object are written and not its member functions



Before we show you how to use this binary input/output functions to write and read the object to file on the disk, we must show you how to open the file. For this, the C++ language provides us stream classes used to perform file input/output operation.




File I/O Stream Classes


In order to perform a binary input/output operation using the read() amd write() functions, C++ provides us a few file stream classes, such as -

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement