Utilizor
Contact Us

C++ Files

Reading and writing files.

C++ Files

The fstream library allows us to work with files.

To use the fstream library, include both the standard <iostream> and the <fstream> header file:

There are three classes included in the fstream library, which are used to create, write or read files:

  • ofstream - Creates and writes to files
  • ifstream - Reads from files
  • fstream - A combination of ofstream and ifstream: creates, reads, and writes to files