File Streams

Now, we shall learn how to communicate with files using C++.

We'll cover the following...

File streams enable you to work with files. They need the header <fstream>. The file streams automatically manage the lifetime of their file.

Whether you use a file stream for input or output or with the character type char or wchar_t there are various file stream classes:

Class Use
std::ifstream and std::wifstream File stream for the input of data of type char and wchar_t.
std::ofstream and std::wofstream File stream for the output of data of type char and wchar_t
std::fstream and std::wfstream File stream for the input and output of data of type char and wchar_t.
std::filebuf and std::wfilebuf Data buffer of type char and wchar_t.

⚠️ Set the file position pointer
File streams used ...

Access this course and 1400+ top-rated courses and projects.