Skip to main content

Section 6.1 File Handling

File handling in C++ also uses a stream in a similar way to the cout and cin functions of <iostream>. The library that allows for input and output of files is <fstream>.
You must declare any file streams before you use them to read and write data. For example, the following statements inform the compiler to create a stream called in_stream that is an input-file-stream object, <ifstream>, and another called out_stream that is an output-file-stream object, <ofstream>.
ifstream in_stream;
ofstream out_stream;
You have attempted 1 of 1 activities on this page.