Login    New User    Forgot Password    Help      

Basis of File Input and Output

GO TO INDEX

Basis of File input and output

We have been dealing with input and output streams this whole time which are cin and cout respectively. The input/output stream is used with the <iostream> library.

In C++, as well as any programming language, you can read and write to a text file (.txt extension). This is done in a similar way to the input/output stream in terms of the library to include with the program. C++ provides 3 of them:

Example

#include <ifstream>
Library to specifically deal with input
of text files. Does not deal with
output.

#include <ofstream>
Library to specifically deal with output
of text files. Does not deal with
input.

#include <fstream>
Library to deal with BOTH input and output.

GO TO INDEX